Entity Framework 4.0 - Introduction

Entity Framework in next level of database programing which is much more flexible and adoptable than earlier methods like Regular ADO.Net and LINQ to SQL.
Comparisons between different models will be seen in another post, but lets not dig much into theory.
Rather we can concentrate on programing part, and thus you can discover what we have in EF 4.0.
We will go step by step how we can use EF 4.0 for rapid development and yet deliver a flexible and a reliable product.

This is the very beginning of Entity Framework 4.0 and we gonna see how we can create a EF Project.

Step 1: Design / Use (Existing) a Database as per your requirements.
In this case i designed a new Database with all infrastructure for a Product Order Catalog.

Step 2: Download Entity Framework 4.0 from this link.

Step 3: Install it and restart the machine so that the integration between Visual studio and the new installables reflect fine.

Step 4: Remember one thing Entity Framework is a better flavor of Ado.Net programing, so its a feature which we need to inculcate in one our project.
Create a class library project. I named it as "EntityConnector"

Step 5: Add a new Item, there select "ADO.Net Entity Data Model" option to create a EF Model file. I named it as "EntityMVCDB".
Step 6: A wizard will appear to guide you through different steps configuring the EF Model file. The next step will be "Choosing Model Content".
We have 2 different approaches.
   i. Create model for existing Database.
  ii. Generating Database from the model we design.
Based on which you want from above options, you have to choose Model Content.
I have chosen first option as i am dealing with existing database or Database first approach.

Step 7: Next step will be configuring the Database connectivity.
Step 8: Once you configure Data connectivity framework will generate required connection strings for the EF Model.
Step 9: Next step will be choosing what are all Data objects you want to include in the EF model from Database.
Step 10: Entity Data Model file is successfully generated with all the Data objects you choose in above step.

Step 11:  Now you are all set to use the entities generated by Entity framework 4.0.
Just to test this i added a class file and will show you how the entities generated were reflecting in code.
Before going into code, lets have a look at properties window of .edmx file.
Look at the Custom Tool Namespace value. That actually represents the name space if Entities generated from that .edmx file.
Coming back to class file here i created a method to create a new category in database using EF Infrastructure.

Thus we created a Entity Data Model project as a first step of learning EF 4.0.

We will see some detailed topics on Entity Framework 4.0 in my next posts.

Is it helpful for you? Kindly let me know your comments / Questions.