public class MYDbContext : DbContext { public DbSet<User> Users { get; set; } public TYDbContext() : base("name=MYEntities") { } protected override void OnModelCreating(DbModelBuilder modelBuilder) { //按model的名字生成表,而不是DbSet的名字 modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); base.OnModelCreating(modelBuilder); } }
时间: 2024-10-10 00:45:59