EF development mode (EF basic Series 9)
EF has three development modes:
1. Code First
2. Model First
3. Database First
Code First: In the Code First method, you completely avoid directly operating the Entity Designer (EDMX ). We started to write our own domain classes and use these domain classes to generate databases.
Model First: In Model First, you directly create entities, relationships, and hierarchy inheritance through the Entity Data Model (EDMX), and then generate databases based on your Model;
Database First: based on an existing Database, add an Entity Data Model and create an EDMX, context, and object class from the Database;
The Entity Data model can be updated at any time. When the database structure changes, DB First also supports views and stored procedures;
In practice, how should we choose the three development modes?
If you already have a domain class, use Code First to create a database based on the domain class. If you already have a database, you can use DB First, you can create an Entity Data Model through an existing database. If you do not have an existing database and you prefer graphical design, you can choose Model First.