MVC 3 Reverse Engineer DB Then switch to the first code

I used EntitFramework before doing codefirst with MVC; however, I have never rebuilt an existing database to get my models.

So what I would like to do is reverse engineer the existing DB and then switch to codefirst so that changes made to the models are automatically reflected in the database by the Entity Framework gods. How do I go about doing this, specifically a reverse engineer and then switch to codefirst? Please have mercy if this is poorly worded or not. I am still new to MVC.

+3
c # asp.net-mvc asp.net-mvc-3 entity-framework code-first


source to share


2 answers


It basically boils down to using tools to auto-generate POCO classes that represent your domain, and then use those classes as the basis for EF Code First and future migrations.

Here's a msdn article describing the process



  • Code first for existing database
+2


source to share


You can modify an existing database by creating an entity data model.

Check the following link. The following describes how to change the database to a CodeFirst approach with all navigation properties and required relationships. This scenario is also very useful for those entity relationships that CodeFirst cannot solve on its own, and the configuration is not very intuitive.



Reverse from ModelFirst to CodeFirst

0


source to share







All Articles
Loading...
X
Show
Funny
Dev
Pics