7

Microsoft releases Entity Framework 4.0 and in it developers can do Code First Development. This is fine and thanks to Microsoft.

I have one confution about code first development. I have worked on Entity Framework in ASP.NET 3.5 SP1 and Visual Studio 2008 SP1. In that we create a database schema and from that we create Entity Data Model. That means we are creating our class model from database. I think this is called data first development.

But when we create Entity Data Model in Entity Framework 3.5 SP1 then there are two options. First is Generate from existing database and another is create a blank model. Suppose I create a blank model and then map it to the database. So we first develop the class models without thinking the database schema and then map it with database. My confution is, is it called code first deveopment? Then why the community people and books are saying that 'It is not possible to impliment code first development in Entity Framework 3.5 SP1'?

To solve my confution I need your help. So please give reply on this post.

Thank you.

  • 1
    Although not a full answer, but please look here: http://stackoverflow.com/questions/5446316/ef-4-1-code-first-vs-model-database-first – Jakub Konecki Nov 29 '11 at 11:24

3 Answers3

5

Code First is availabe since Entity Framework 4.x. So you cant generate a Database from your Code Model in 3.5 SP1.

Basicly there are 3 Types:

  1. Database First (the Database already exists, you create the edmx from that using the Wizard)
  2. Model First (you create a Database Model using the Designer, Entity Framework gerenates a Database from that)
  3. Code First (your create your Code, Entity Framework creates a Database from that)

More Informations: Code-First Development with Entity Framework 4

dknaack
  • 56,707
  • 23
  • 140
  • 187
3

Actually this is called "model-first" development. Although the default designer in Visual Studio directly turns your model into code, it is actually just a "conceptual model" you see in the designer. Where you define the properties and relationships, the designer than uses a "Code Generation Strategy" which creates the .NET classes for you.

The "new code-first" approach lets you create the .NET classes directly and it than figures out what the "conceptual model" looks like.

J. Tihon
  • 4,359
  • 22
  • 19
1

When you create a blank model and then trying to model the domain is called Model First. you can visually design the entity model in the designer.Then it will genarate the relationships for you.

In code first you don't have a visual designer . You have to code the relationships yourself. So it's called Code First.
Have a look at this for more details

Code-first vs Model/Database-first

Community
  • 1
  • 1
Jayantha Lal Sirisena
  • 20,611
  • 10
  • 65
  • 90