1

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.

Max
  • 6,821
  • 3
  • 43
  • 59
aykut
  • 19
  • 6

1 Answers1

0

Man, it's duplicated, but the answer is here by Yurko: https://stackoverflow.com/a/25640707/3902210

enter image description here

Amaurys Sánchez
  • 102
  • 1
  • 1
  • 10