Skip to content

Instantly share code, notes, and snippets.

@rowanmiller
Last active August 27, 2017 23:04
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rowanmiller/88261afd0baae7fb9b04 to your computer and use it in GitHub Desktop.
EF7 | Pluralizing table names
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
foreach (var entity in modelBuilder.Model.GetEntityTypes())
{
modelBuilder.Entity(entity.Name).ToTable(entity.Name + "s");
}
}
@julielerman
Copy link

Geeze, couldn't be easier once you know!

@JMooreWeb
Copy link

This wouldn't work for all cases eg. Property => Properties (not Propertys)

@JMooreWeb
Copy link

This works for me.

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity().ToTable("Properties");
}

@Mahmoudsaeed111
Copy link

How can i make favorite component with angular 2

@bradykelly
Copy link

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