Gareth Lewis
Gareth Lewis

Reputation: 751

ASP.NET MVC 3 EF Code First - also use existing database

I am in the process of writing a new web application. I am using ASP.NET MVC 3 with Entity Framework code first. The database is automatically created and everything looks good so far.

However, we already have an existing database that holds details of all our current users and I want to be able to retrieve data from this database table in my new project. Is this possible using EF Code First and if so, how would I go about this?

Thanks in advance.

Upvotes: 3

Views: 3509

Answers (2)

dknaack
dknaack

Reputation: 60438

Description

I have done the same a few months ago. You can map your Model to an existing Database. Scott Guthrie has blogged about it. You can use the Enity Framework Power Tools to create your models from your existing Database.

More Information

Upvotes: 3

Per Kastman
Per Kastman

Reputation: 4504

Yes, it's possible. Have a look at Scott Gu's blog where he describes how to do it. http://weblogs.asp.net/scottgu/archive/2010/08/03/using-ef-code-first-with-an-existing-database.aspx

Upvotes: 1

Related Questions