Entity Framework Development Workflows
0 (0 Likes / 0 Dislikes)
[msdn]
[www.msdn.com]
Hi. I'm Rowan Miller.
Let's take a look at the different ways you can use entity framework to access a relational database
using classes in your .net application and to do framework supports
for basic development workflows.
All 4 workflows are equally valid, and a couple of simple questions
can help you find the workflow that's right for you.
The first of these questions is something that's outside of your control,
and that is are you targeting a new database, that is a database that doesn't exist
or an empty database that needs tables added to it,
or are you targeting an existing database that has already been created and populated with tables?
The second question is something totally inside your control,
and that is would you rather create a model using boxes and lines in a designer
or by writing code?
Let's take a look at the 4 workflows that enable each of these combinations.
The first one is Model First.
In Model First I uses boxes and lines in a designer to create a model.
I can then generate a database from the model.
The classes that I'm going to interact with in my application are generated for me
based on the boxes and lines that I draw in the designer.
The second one is Database First.
In Database First I reverse engineer our boxes and lines model
using the designer.
I can then tweak the mapping in the shape of my classes in the design surface.
Again the classes that I interact with in my .net application
are automatically generated for me based on the boxes and lines.
The third option is Code First to a new database.
In this workflow I define my model using code.
My model is made up of the domain classes that I'm going to interact with in my application,
and optionally I can supply some additional mapping and configuration code
to further specify the model.
Again the database is created for me from the model.
If I change my model, I can then use Code First Migrations to evolve the database.
The final workflow is Code First to an existing database.
In this I still define my model using code,
but this time it's mapping to an existing database.
There are also some tools that I can use to reverse engineer this model for me.
Now that you know about the 4 different workflows,
head to msdn.com/data/ef to learn more about them.
[msdn]
[www.msdn.com]