I have some models and tables in EF that you can see one of those here:
Now when I want to generate database from model it adds 's' to name of tables in generated sql:
CREATE TABLE [dbo].[Options] (
[Id] int IDENTITY(1,1) NOT NULL,
[Name] nvarchar(50) NOT NULL,
[Price] int NOT NULL
);
I also disabled pluralizing of names as this but nothing changed:
This cause errors on deploying web application. How can I prevent pluralizing ?
Just override the OnModelCreating method and remove that “PluralizingTableNameConvention” convention. So you are telling Entity Framework not to pluralise table names, simply add
Updated
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
It will remove the Pluralising convention that is by default attached to all model builders
Also you need to add a namespace
System.Data.Entity.ModelConfiguration.Conventions;
Hope it will help
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With