Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF 4.1 Code Only?

As far as I can tell (correct me if I'm wrong), there are two main approaches to using Entity Framework:

  1. Model First: start with a predefined database and let EF create the code for you.
  2. Code First: write the code, and let EF create the database for you.

I have an existing database and I'd like to write the code myself. Is this "Code Only" approach supported? Does such an approach even make sense in the context of EF?

like image 873
MCS Avatar asked Jun 17 '11 02:06

MCS


1 Answers

I disagree with most of the other answers. From what I've seen, the EF "Code First" technology is really just a way to define your model using conventions, annotations, or a fluent mapping definition, rather than an EDMX file. If you write your "Code First" files to mirror your database schema, there is no reason that Entity Framework would be unable to produce the appropriate queries and statements using LINQ to Entities.

For more information, see Scott Guthrie's post on Using EF "Code First" with an existing database.

like image 75
StriplingWarrior Avatar answered Oct 03 '22 06:10

StriplingWarrior