I want to using mysql with asp.net mvc 4. Added reference.
- Mysql.Data.dll
- Mysql.Data.Entity.dll
- Mysql.Web.dll
Added web.config file in connection string.
<add name="DBEntities" connectionString="Server=localhost; port=3306; Database=dbprojectname; Uid=root; Pwd=;" providerName="MySql.Data.MySqlClient" />
Added Model
public class User
{
[Key]
public int user_id { get; set; }
public string username { get; set; }
public string password { get; set; }
public string url { get; set; }
public string name { get; set; }
public string surname { get; set; }
public string email { get; set; }
public string avatar { get; set; }
public string rank { get; set; }
public string status { get; set; }
public DateTime date { get; set; }
}
public class DbEntities : DbContext
{
public DbSet<User> User { get; set; }
}
and create controller but i have a error
Unable to retrieve metadata for 'WSDashboard.Models.User'. Using the same DbCompiledModel to create contexts against different types of database servers is not supported. Instead, create a separate DbCompiledModel for each type of server being used.