Application Models
Last updated
Last updated
In the ASP.NET MVC framework, the code-first approach is a development model where you first write the code that creates the data access layer, then you write the code that creates the controllers and views.
In the code-first approach, you create a model, which is a class that represents the data in the application. Then you create a data access layer, which is a set of code that reads and writes data to a data store.
Note that a code-first approach does not have to use a database. You could use the code-first model to create any kind of data.
Install NuGet Packages
Create Model Classes
Configure the Database
Create Database using Migration
Update Database using Migration
Code first
Design entities and verify/customize generated migrations
Verify schema definitions and changes
Per commit
N/A
Track entities, DbContext
, and migrations
Database first
Reverse engineer after changes and verify generated entities
Inform developers when the database changes to re-scaffold
N/A
Per schema change
Track extensions/partial classes that extend the generated entities
Hybrid
Update fluent configuration to map whenever entities or database change
Inform developers when the database has changed so they can update entities and model configuration
N/A
N/A
Track entities and DbContext