Skip to content

Instantly share code, notes, and snippets.

@rowanmiller

rowanmiller/Demo.cs

Last active Aug 27, 2017
Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@julielerman julielerman commented Dec 7, 2015

Geeze, couldn't be easier once you know!

@jmooreweb

This comment has been minimized.

Copy link

@jmooreweb jmooreweb commented Feb 20, 2016

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

@jmooreweb

This comment has been minimized.

Copy link

@jmooreweb jmooreweb commented Feb 20, 2016

This works for me.

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

@Mahmoudsaeed111

This comment has been minimized.

Copy link

@Mahmoudsaeed111 Mahmoudsaeed111 commented Jul 31, 2016

How can i make favorite component with angular 2

@bradykelly

This comment has been minimized.

Copy link

@bradykelly bradykelly commented Aug 12, 2016

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
You can’t perform that action at this time.