How do I toggle this convention PluralizingTableNameConvention
for only a single table/DbSet? As far as I can tell, I can only do this to all the DbSets
If you have only one entity which is mapped to a table that is not pluralizeed then you can remove the PluralizingTableNameConvention
and manually configure the table name of the entity.
public class MyContext : DbContext
{
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.Entity<Item>().ToTable("Items");
}
}
Or if it is the otherway around
public class MyContext : DbContext
{
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Item>().ToTable("Item");
}
}