In this section we will discuss code-first workflow in detail. Some developers think that code-first workflow is only good for a Greenfield project and not when you have an existing database. In this section we will explore that how can we use code-first workflow successfully with an existing database or a new database.
We have already discussed about code-First workflow in the article three approaches of EF , if you have directly landed here then I will highly recommend you to read that article first , so that you will have some idea about Entity Framework in general and about it's different approaches .
Also read the article which approach is really better , to know the pros and cons of code-first approach and then decide whether you want to proceed with code-First approach or database-First approach.
This section covers following topics :
• code-first workflow with a new database.
• code-first with an existing database.
• Migrations in detail.
• Different ways to seed database with test data or reference data.
• Overriding Code-First convention with data-annotation and fluent API.
• Establishing relationship between tables correctly using Fluent API.