Tuesday, December 10, 2013

What is Code-First?


Entity Framework introduced Code First approach from Entity Framework 4.1. Code First is mainly useful in Domain Driven Design In the Code First approach, you can focus on the domain design and start creating classes as per your domain requirement rather than design your database first and then create the classes which matches your database design. Code First APIs will create the database on the fly based on your entity classes and configuration.

So as a developer, you first start writing C#/VB.net classes rather than focusing on database design and then when you run the application, Code First APIs will create the new database or map your classes with existing database before running your application.

So the basic workflow would be:

Write code-first application classes → Hit F5 to run the application → Code First API creates new database or map with existing database from application classes → Inserts default/test data into the database → Finally launch the application


Let’s see simple code first example in the next chapter.

No comments:

Post a Comment