Preview of useful design-time features for DbContext.
When right-clicking on a C# project, the following context menu function is supported:
1) Reverse Engineer Code First - Generates POCO classes, derived DbContext and Code First mapping for an existing database.
Reverse engineer worked on my database of 13 entities that was created model-first in EF 4.0. It even put IsRowVersion() on my timestamp columns!
Note that it automatically downloads the latest entity-framework, which means it will grab an unstable RC version if you didn't explicitly download one first. (The tool should probably honor the user's last settings in Visual Studio's "Manage NuGet Packages" if possible)
Many of the negative reviews complain about things which have nothing to do with this tool. One complains it crashes when you have 1392 tables. That's not what the Entity Framework is for! Another is a problem with source control. Yet another is about generating views.
Great tool, but the reverse engineer needs a dialog to select specific tables, I tested the tool on a data base with 1267 tables and have to wait to much time to generate the classes, and after that, delete all the unnecesary files.
Until you can select individual tables to add, I don't find this very useful.
I am writing a small app to view To-Dos in a database of 100 tables, and have to wait for all of those classes to generate, then deleting all of unused data, is challenging and a waste of my time. Please make these changes.
error : Running transformation: System.NullReferenceException: Object reference not set to an instance of an object.
However I have the solution for anyone else who reads this:
Right click on the project > Entity Framework > Custom Reverse Engineer Templates
This will add a few .tt files into your projet so that you can now change them (and fix the bug!)
- Open Mapping.tt - Search for the line "if (fixedLengthFacet != null && (bool)fixedLengthFacet.Value)" - Replace this with "if (fixedLengthFacet != null && fixedLengthFacet.Value is bool && (bool)fixedLengthFacet.Value)" - Run Entity Framework > Reverse Engineer Code First
This is a great tool. It's still flaky enough to deserve the "Beta" appellate, but the code generated is still a tremendous time-saver for production work.
The biggest feature I'd like to see is the ability to select which tables to generate entities for. I'm using this tool for 1) working on a new app with a lot of churn from the DBA and 2) refactoring an old app. For both, I want to work within bounded contexts that are fairly stable. I don't need to rummage through 100+ files of junk for the bits I don't need.
Even without that feature, this tool is a huge help.