Entity Framework Step By Step 1
Thought of writing a series of posts to explain entity framework Step by step so that anyone can easily understand the concepts behind that. This will be the starting point of that.
What is Entity Framework?
“Entity Framework (EF) is an object-relational mapper that enables .NET developers to work with relational data using domain-specific objects. It eliminates the need for most of the data-access code that developers usually need to write.”
As the first step to begin entity frame work the first thing we have to do is to identify which workflow we should adopt. Entity Framework provides 4 different workflows we can adopt for our development based on our requirement.
Which Workflow We should Adopt?
When deciding which workflow we should select there are four question we should answer.
1. Are you targeting new Database , which is empty & tables need to be created?
2. Are you targeting existing Database where tables are already populated?
3. Would you prefer creating the model using boxes & lines in the designer?
4. Would you prefer creating the model by writing code?
Based on your answers, looking at the image above you can decide which development workflow of entity framework suits your requirement best. Lets see what are the features available in these four workflows in brief.
Model First
1. We Can create the model using the boxes & lines available in the designer
2. Then we can generate the Database from the model
3. Classes that we interact within the code will be auto generated using the model we designed using the designer.
Database First
1. You can do reverse engineering & create he boxes & lines in the designer using a existing data base
2. Then classes that we interact within the code will be auto generated using the model we designed using the designer.
Code First (New Database)
1. Create the model by defining the domain classes in the code.
2. Database is created from the model.
3. If you make any changes to the model , can use code first migrations to evolve the database.
Code First (Existing Database)
1. Create the model by defining the domain classes in the code based on the existing database.
2. There are some tools available for reverse engineering.
Now You can decide which development workflow to be adopted.
Lets discuss these four workflows in detail in the following posts.
Comments
Post a Comment