3

I have code first classes which are generated from my existing db using ADO.NET Entity Data Model. Now I've added some new tables to the database.

I want to know if its possible to create associated code classes from the new db tables without (re)creating the model again from scratch?

Corey Adler
  • 15,897
  • 18
  • 66
  • 80
Laziale
  • 7,965
  • 46
  • 146
  • 262
  • This question is a close relative of this one; http://stackoverflow.com/questions/22637350/how-to-synch-model-after-using-code-first-from-database-using-entity-framework-6 where the answer is, no, this is not possible with a "code first from database" approach. – n00b Jan 27 '16 at 18:20

1 Answers1

4

Yes it is, if you use Reverse Engineer Code First to do so. It will create POCOs exactly like Code-First, but it will do so based completely on the current database. No .edmx file and no T4 template. Just Code-First.

You should know, by the way, that this (along with regular Code-First) are going to be the only ones allowed in EF7. They are getting rid of many things to try to slim it down, and both Model- and Database-First got the ax (at least, for now). This blog post from Microsoft's ADO.NET blog explains that, along with some other features.

Corey Adler
  • 15,897
  • 18
  • 66
  • 80
  • 5
    Not sure why this was an accepted answer since the question was clearly asking if the tool could be run again without recreating the model. Based on the information in the link you do have to delete and recreate the existing model class in order to pick up the new schema changes. – Christopher Elliott Oct 26 '15 at 23:14
  • 1
    blog post link is broken – Michael Freidgeim Aug 10 '16 at 02:25