can ef5 work with mysql when using code first approach? when i'm trying to add new items to a not yet created table I'm getting "Table 'clients' doesn't exist. if I'm switching to mssql everything works well.
使用代码第一种方法时,ef5可以使用mysql吗?当我试图将新项添加到尚未创建的表时,我得到“表'客户'不存在。如果我切换到mssql一切正常。
this is my dbcontext
这是我的dbcontext
public class MyDBContext : DbContext
{
public PowerToolsDBContext()
: base("Name=MyContext") { }
public DbSet<User> Users { get; set; }
public DbSet<Client> Clients { get; set; }
public DbSet<JobData> Jobs { get; set; }
}
1 个解决方案
#1
1
Problem solved after adding database initializer
添加数据库初始化程序后问题解决了
static MyDBContext()
{
Database.SetInitializer<MyDBContext>(new DropCreateDatabaseIfModelChanges<MyDBContext>());
}
#1
1
Problem solved after adding database initializer
添加数据库初始化程序后问题解决了
static MyDBContext()
{
Database.SetInitializer<MyDBContext>(new DropCreateDatabaseIfModelChanges<MyDBContext>());
}