0
I created a web project with MVC and Entity framework 4.5, and MYSQL database.
added the dlls Mysql.Data Mysql.Data.Entity and Mysql.web
I made all settings as per images below
I followed the step by step and my Bank was added as image below:
I created my entity by name Client. Follow code:
namespace MysqlConnectorMVC.Models
{
public class Cliente
{
public int Id { get; set; }
public string Nome { get; set; }
public string Observacao { get; set; }
public int Idade { get; set; }
public string Email { get; set; }
public string Login { get; set; }
public string Senha { get; set; }
public string ConfirmarSenha { get; set; }
}
}
I also created my context class:
namespace MysqlConnectorMVC.Data
{
public class Context : DbContext
{
public Context()
: 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 image below:
I get the following error:
I already looked for the solution to this error, even here in the stack, but I could not fix.
My question is this: How to fix this error? What I’m doing wrong?
select your edmx and click F4 and go to the Connection String property and copy and paste to your webconfig and see if you can solve it.
– Junior Porfirio