Reputation: 7
I've tried the way it's mentioned in EF4 Code First make tables names singular but in my case EF6 is not recognizing OnModelCreating(). It says "No suitable method found to override". Is there any alternate way or any way to fix it?
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
Upvotes: 0
Views: 65
Reputation: 13272
I am not certain of the ModelBuilder Type but I can say for a fact I just tested my older Code First on EF 6.1.3 and it works fine with this:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.HasDefaultSchema("dbo");
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
...
}
I think you needed DbModelBuilder versus ModelBuilder. I am not sure of that thread but know I just ran mine just now and that was the only thing I noticed differently. I learned EF Code First from two tutorials and this one by far was better than the other by leaps and bounds: http://www.entityframeworktutorial.net/code-first/entity-framework-code-first.aspx
Upvotes: 1