How turn off pluralize table creation for Entity Framework 5?

荒凉一梦 提交于 2019-11-27 08:50:59

You can write this code in OnModelCreating method:

modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
Ladislav Mrnka

If you don't want EF to create tables and manage consistency between you model and database just use this at the startup of your application:

Database.SetInitializer<CountryContext>(null);

Using LINQ in EF 6.0:

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
    base.OnModelCreating(modelBuilder);
    var conventions = new List<PluralizingTableNameConvention>().ToArray();
    modelBuilder.Conventions.Remove(conventions);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!