0

I have created a class name History with required columns and used the package manager console to update the database the thing that I have noticed is that the table in database created is Histories.

Wanted to know that how History to Histories got created.

Another table with Transactions created which is correctly created.

All the table name ending with y alphabets gets converted to ies would to understand where is such kind of logic written.

Dave
  • 51
  • 1
  • 8
  • http://stackoverflow.com/questions/4796543/how-do-i-singularize-my-tables-in-ef-code-first – Steve Feb 12 '17 at 11:05
  • Its convention (pluralizing the table name). Refer [this question/answer](http://stackoverflow.com/questions/4796543/how-do-i-singularize-my-tables-in-ef-code-first) –  Feb 12 '17 at 11:05
  • Helpful,understood thanks @Steve & Stephen – Dave Feb 14 '17 at 17:17

1 Answers1

0

If you add the annotation '[Table("YourTableName")]' to your table class, it should create your table in the db as what you named it and not "YourTableNames".

Like this:

[Table("MyTable")]
public class MyTable

Also, in your db context (i.e., ApplicationDbContext), you would usually pluralize the dbsets with type of tablename tablenames. As in:

    public DbSet<TableName> TableNames { get; set; }

As mentioned in the comments, it's part of the conventions. Not sure if that explains it, but it should be a start.

nocturns2
  • 663
  • 10
  • 17