We finally got things squared away so that we can start using code first.
When I run "Enable-Migrations" it creates a file with InitialCreate in it's name.
(like here: http://msdn.microsoft.com/en-us/data/jj591621.aspx#enabling)
That file has plural database table names instead of singular.
I do have this line in my initiazlizer, which is correct:
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
but the file that is being created with the migration has all pluralized names.
This becomes annoying when I add a migration and the first thing it does is drop every pluralized table in the DB and re-add them as singular.
Can I pass a parameter into the "Enable Migrations" command or something to tell it to not pluralize?
This behavior has been fixed, I'm unable to reproduce it with EF 6.1.0. I created the database using an initializer first, than ran Enable-Migrations
(of course OnModelCreating()
already includes the line removing the PluralizingTableNameConvention
). The generated migration (with InitialCreate
in its name) generates tables named in the singular. So if you're able to update EF your problem will be gone.
If not: did you try to override the table names with their singular form using the Table attribute? At least generated migration code does respect it (I haven't checked with an older EF version than 6.1.0 though).
[Table("MyEntity")]
public class MyEntity
{
// .. your properties go here.
}
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