Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Program against a database project using entity framework

Using Visual Studios 2010 I'm creating a project that has a database.

I decided to try to use one of those Database Projects that allow you to manage the database in source control along with the code.

I also think I will use entity framework as my data access tool.

Are there any good solution to tie the EF 4.0 project to the database being managed in the Database project (assuming it's a new db)?

like image 656
Ingó Vals Avatar asked Sep 06 '11 09:09

Ingó Vals


People also ask

What databases work with Entity Framework?

EF Core works with many databases, including SQL Database (on-premises and Azure), SQLite, MySQL, PostgreSQL, and Azure Cosmos DB.

How do I create a code first from an existing database?

To use code-first for an existing database, right click on your project in Visual Studio -> Add -> New Item.. Select ADO.NET Entity Data Model in the Add New Item dialog box and specify the model name (this will be a context class name) and click on Add.


2 Answers

You simply use your database project to create database for you and you use Database first approach with Entity framework (that means you will use wizard and update from database to create entity model for you).

like image 160
Ladislav Mrnka Avatar answered Jan 01 '23 22:01

Ladislav Mrnka


I found Scott Guthries 'Code-first' tutorial to be quite good:

http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx

Let me know if that doesn't quite scratch the itch, I've got a couple of others bookmarked.

like image 25
Russ Clarke Avatar answered Jan 01 '23 23:01

Russ Clarke