EF mysql
namespace MySqlCodeFirstDemo { [DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))] //可以执行mysql代码使之生效 public class MySqlContext : DbContext { public DbSet<User> Users { get; set; } } public class User { [Key] public int Id { get; set; } [MaxLength(255)] public string Name { get; set; }
转https://blog.csdn.net/tangolivesky/article/details/46507723?tdsourcetag=s_pcqq_aiomsg
internal sealed class Configuration : DbMigrationsConfiguration<MySqlCodeFirstDemo.MySqlContext> { public Configuration() { AutomaticMigrationsEnabled = false; // register mysql code generator SetSqlGenerator("MySql.Data.MySqlClient", new MySql.Data.Entity.MySqlMigrationSqlGenerator()); //加上这句不知道有啥用 ,不加也没事 } protected override void Seed(MySqlCodeFirstDemo.MySqlContext context) {