I created a web project with MVC and entity framework 4.5, and MYSQL database.
I added the MySql.Data MySql.Data.Entity and MySql.web
I made all the settings as images below
IfollowedthewalkthroughandmyBankwasaddedaspicturebelow:
IcreatedmyentitybynameCustomer.Hereisthecode:
namespaceMysqlConnectorMVC.Models{publicclassCliente{publicintId{get;set;}publicstringNome{get;set;}publicstringObservacao{get;set;}publicintIdade{get;set;}publicstringEmail{get;set;}publicstringLogin{get;set;}publicstringSenha{get;set;}publicstringConfirmarSenha{get;set;}}}
Ialsocreatedmycontextclass:
namespaceMysqlConnectorMVC.Data{publicclassContext:DbContext{publicContext():base("name=restauranteEntities")
{
}
public DbSet<Cliente> Cliente { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
base.OnModelCreating(modelBuilder);
}
}
}
My Connection String is below:
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-MysqlConnectorMVC-20171012215253;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-MysqlConnectorMVC-20171012215253.mdf" />
<add name="restauranteEntities" connectionString="metadata=res://*/ClienteModel.csdl|res://*/ClienteModel.ssdl|res://*/ClienteModel.msl;provider=MySql.Data.MySqlClient;provider connection string="server=localhost;user id=root;password=toor;persistsecurityinfo=True;database=restaurante"" providerName="System.Data.EntityClient" />
But when trying to create my Controller from my entity and my context as below:
Igetthefollowingerror:
I've tried the solution to this error, even here in the stack, but I could not solve it.
My question is: How to solve this error? What am I doing wrong?