0
votes

I'm about to start on a new project, and while most of my team's experience is with using VS Database projects and SSMS directly on a database, we would like to use EF instead. However, time constraints won't allow us to take the time to fully learn EF before implementation.

At first glance, the code-first migrations in EF Code-first seem like they would be a very valuable tool, but with code-centric database first (they don't seem to have a good name for this) code migrations don't appear to be a feature. Instead, only projects that start as code-first seem to support this.

Is it possible to start with a database, and then (at some point during development), somehow convert to Code-first, in order to take advantage of Code First Migrations?

1

1 Answers

1
votes

You could try EF Power Tools (not an 'answer' but something to try and have in mind).

It has the Reverse Engineer Code First which should create POCO-s etc. for you.

However it is an experimental tool (in Beta), and has a few issues setting up - but you could give it a try.

Other than that - it could be tricky, so it's better you start 'earlier' -
but IMO there isn't anything that you couldn't actually transfer manually - at any point - providing your database is not using too much of the 'complex features' and relying on some advanced scenarios.

Just have in mind some of the limitations that CF imposes (e.g. like having to resort to 'Seed'-ing and manual SQL for complex scenarios, no native support for UDF, stored procedures - but you can still manually specify it...) - so that you avoid basing your Db design on such things - but rather work things 'the code first way' - and possibly adding couple extra manual fixes where needed.

And take a look at this post (links):
Entity Framework - Reverse Engineer Code First - Overwriting Changes

http://romiller.com/2012/05/09/customizing-reverse-engineer-code-first-in-the-ef-power-tools/