Entity Framework Code First Options
Is the database migration automatically written to match all class properties, or can I use a general class and then pick which properties I wish to be included in the db? How do I manage classes as table objects? Does each model become a table?


Suraj SahooRank #382 · 6.6K reputationPosted Feb 11, 2015, 9:21 AM EST
http://www.google.co.in/url?q=http://www.entityframeworktutorial.net/code-first/entity-framework-code-first.aspx&sa=U&ei=z6rbVIn4A4zluQT6poHgBg&ved=0CAsQFjAA&usg=AFQjCNHXrGApef8mPSHLY8B5kkpoArcnLQ
What happens is you create a class with properties and you specify the id or primary key with key attribute. Thus when enable migration is done it creates the migration which picks the classes and its properties and on update database the tables are created based on the connection strings.
accept if helps
thanks
Jignesh TrivediRank #16 · 50.3K reputationPosted Feb 11, 2015, 6:10 PM EST
Hi,
No
Each model does not become a DB table, If you decorated them with "Table" attribute or define dbset property in context class then it become DB table.
Generally db table name and column name is same as model class name and properties name but we can change also.
Please refer
https://msdn.microsoft.com/en-us/magazine/hh126815.aspx
hope this will help you.
Rollin Shultz3 reputationPosted Feb 12, 2015, 4:46 AM EST