This feature provides a single entry point for creating an EF model that shows developers all the options that are available and helps them find the option that is right for them.

 

The Problem

There are a number of different entry points for creating a new EF model and no easy way for a developer to see all the options that are available and make an informed decision about which to use.

  • For EF Designer based models that target a new or existing database you use Add -> New Item… -> ADO.NET Entity Data Model.
    Existing
  • For Code First models that target an existing database you install the EF Power Tools and use the Reverse Engineer Code First tool. You can also just start hand writing code to map to an existing database (this is one of the benefits of Code First and will continue to be a valid and supported option).
    CF
  • For Code First that target a new database you just start writing code (this is one of the benefits of Code First and will continue to be a valid and supported option).

 

The Solution

Update the Add -> New Item -> ADO.NET Entity Data Model wizard to support creating Code First models. The first screen will allow developers to select a Code First model or an EF Designer model. They can also choose between a new and existing database.

clip_image005

  • Selecting Code First and Generate from Database will use the existing wizard screens for EF Designer based models but will then use the functionality from the EF Power Tools to produce a Code First model.
  • Selecting Code First and Empty Model will add a template derived DbContext to the user’s project.
  • The existing functionality for EF Designer based models will remain in place

Last edited Aug 28, 2012 at 12:38 AM by RoMiller, version 5

Comments

jlerman Nov 8, 2012 at 7:45 PM 
I know you know that I'm chomping at the bit for the code first reverse engineer tool to let us pick objects. I love this solution but am worried about how far off it will be. If very far, is it possible to just tweak the power tool for now? Look at this email I just got:
"I used the EF PT Beta 2 tool ... my dual-quad-core-Xeon with 24GB RAM and SSD drive ThinkStation huffed and puffed for about two hours, created 868 new classes and an equal amount of mapping classes using Fluent API … and it is still huffing and puffing … "

lucamorelli Sep 18, 2012 at 9:40 AM 
with code first may be nice the option to choose the use of attribute or EntityTypeConfiguration mapping class to define the properties

HansKrJensrud Aug 28, 2012 at 5:18 PM 
It may be an idea to set preferred "EF Model Type in charge" as an overall EF property to get more attention to selecting the preferred working environment rather than how to get started. After the preferred working environment is selected it may be specified how to get started in this environment and which options to use in this case e.g. how the to other options (if selected) should be kept current/synchronized. By using this method, it should also be possible to change the preferred working environment. By using this method all options would be presented up-front and successive choices would hopefully follow in a natural manner. A change to one of the two other options should result in a question about changing the EF Model Type in charge or make an update to the model type in charge (and keep the selected model type as preferred). This may also prepare for a future with more model types, or a fully automated synchronized model which makes no difference independent of where the changes are made (as with WPF where it is the same if changes are made on screen or in in XAML).

fujiy Aug 28, 2012 at 11:54 AM 
Would be nice if Code First from Database preserve previous manual changes as Designer Model does