Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert my EF Code-First to Database first?

I want to convert my code-first project to Database first. Is there an automated way or should I just delete the entities and context code and create a model from the created database?

like image 581
Nean Der Thal Avatar asked Feb 12 '14 15:02

Nean Der Thal


People also ask

Which is better code first or database first in Entity Framework?

Versioning databases is hard, but with code first and code first migrations, it's much more effective. Because your database schema is fully based on your code models, by version controlling your source code you're helping to version your database.

How do I create a database first in Entity Framework?

Step 1 − Let's create a new console project with DatabaseFirstDemo name. Step 2 − To create the model, first right-click on your console project in solution explorer and select Add → New Items… Step 3 − Select ADO.NET Entity Data Model from middle pane and enter name DatabaseFirstModel in the Name field.

How do I know if code first or database first?

In the code first approach, the programmer has to write the classes with the required properties first, while in the database first approach, the programmer has to create first the database using GUI.


1 Answers

It appears Entity Framework Power Tools supports a feature called "Reverse Engineer Code-First". You can download it here.

like image 103
Adam Modlin Avatar answered Oct 25 '22 17:10

Adam Modlin