Logo 
Search:

Entity Framework Articles

Submit Article
Home » Articles » Entity Framework » GeneralRSS Feeds

Code First for Existing Database with POCO class auto generated

Posted By: Vivek Patel     Category: Entity Framework     Views: 11628

In this article i will explains you how to use Entity Framework CodeFirst Approach for Existing database with POCO class generated on the fly (Auto Generated)

Since we want to generate POCO class on the fly we have to download EF4.x POCO Entity Generator for C#

Step 1: Download EF4.x POCO Entity Generator for C# http://visualstudiogallery.msdn.microsoft.com/23df0450-5677-4926-96cc-173d02752313

Step 2: Create Visual Studio Project



Step 3: Choose Internet Application Template



In order to generate POCO class for existing database for EF Code First

Step 4: Right Click Project in Solution Explorer, then Click on Entity Framework and then click on Reverse Engineer Code First



Step 5: Make Connection to your existing database and Test Connection

And this will generate all necessary POCO class for your database. Here is how your Model folder looks after POCO class auto generation completes.

Model Folder


Step 6: Build your Asp.net MVC Project to make sure that everything is working


Lets Displaying Customer Records 

Step 7: Right click controller folder and choose Add Controller

Controller Folder


Step 8: Name it as CustomerController and Choose Customer for Model and NorthwindContext for DBContext

Add Controller Dialog Box

Click ok and it will generate CRUD Operations for Customer Class


Step 9: Run the Project and Type following in URL

Asp.net MVC WEbsite

I hope you enjoyed this article. With All new support for Entity Framework now you can very easily use CodeFirst approach for your existing database.

  
Share: 

 
 
 


Vivek Patel
Vivek Patel author of Code First for Existing Database with POCO class auto generated is from United States. Vivek Patel says

I have started working in .Net Technology since its beta release and lucky to got chance to work on .Net 1.1, 2.0 and now working on .Net 3.5. I have worked in both C# and VB.Net for Asp.net Projects. I can also provide Sharepoint development needs. I can efficiently switch role from Tech Lead and Developer. I have comprehensive knowledge of Asp.net Development. I have been award Microsoft Most Valuable Award twice in Asp.net Technology.

Blog: http://dotnetguts.blogspot.com

 
View All Articles

 

Other Interesting Articles in Entity Framework:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
Arron Lee from United States Comment on: May 14
Thank you for your sharing.
Before I encountered this one, I used to surf the following web to ask for help.
All the SDKs offered by it works well.
You can have a try.
http://www.yiigo.com/

View All Comments