Last active
August 27, 2017 23:04
-
-
Save rowanmiller/88261afd0baae7fb9b04 to your computer and use it in GitHub Desktop.
EF7 | Pluralizing table names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void OnModelCreating(ModelBuilder modelBuilder) | |
{ | |
foreach (var entity in modelBuilder.Model.GetEntityTypes()) | |
{ | |
modelBuilder.Entity(entity.Name).ToTable(entity.Name + "s"); | |
} | |
} |
This wouldn't work for all cases eg. Property => Properties (not Propertys)
This works for me.
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity().ToTable("Properties");
}
How can i make favorite component with angular 2
Just adding an 's' to pluralize a name is such a piss poor attempt at doing anything, why bother at all?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Geeze, couldn't be easier once you know!