Поделиться через


EF Power Tools Beta 3 Available

 


The information in this post is out of date.

Visit msdn.com/data/ef for the latest information on current and past releases of EF.

For EF Power Tools see https://msdn.com/data/jj593170


The Entity Framework Power Tools provide additional design-time tools in Visual Studio to help you develop using the Entity Framework. Beta 3 of the Power Tools is now available.

 

Where do I get it?

The Entity Framework Power Tools are available on the Visual Studio Gallery.

You can also install them directly from Visual Studio by selecting 'Tools -> Extension Manager...' then searching for "Entity Framework Power Tools" in the Online Gallery.

 

What's new in Beta 3?

Beta 3 is primarily a bug fix release and includes fixes for the following issues:

 

Future of the Power Tools

We are making an effort to consolidate and simplify the tooling for EF. As part of this effort we will be taking the functionality from the Power Tools and incorporating it into the EF Designer. There is a feature specification on our CodePlex site that outlines some of this work.

This means that we won't be releasing an RTM version of the Power Tools. However, we will continue to maintain Beta releases of the Power Tools until the functionality becomes available in a pre-release version of the EF Designer.

 

Support

This release is a preview of features that we are considering for a future release and is designed to allow you to provide feedback on the design of these features.

If you have a question, ask it on Stack Overflow using the entity-framework tag.

 

Compatibility

The Power Tools are compatible with Visual Studio 2010 and 2012 and Entity Framework 4.2 thru 6.0.

There are some temporary limitations that we will address in a future release:

  • The 'Generate Views' functionality is currently disabled when using EF6.
  • The 'View Entity Data Model (Read-only)' functionality does not work when using EF6 in Visual Studio 2010.

 

What does it add to Visual Studio?

EF Power Tools Beta 3 is for Code First, model-first, and database-first development and adds the following context menu options to an 'Entity Framework' sub-menu inside Visual Studio.

When right-clicking on a C# project

  • Reverse Engineer Code First 
    This command allows one-time generation of Code First mappings for an existing database. This option is useful if you want to use Code First to target an existing database as it takes care of a lot of the initial coding. The command prompts for a connection to an existing database and then reverse engineers POCO classes, a derived DbContext, and Code First mappings that can be used to access the database.
    • If you have not already added the EntityFramework NuGet package to your project, the latest version will be downloaded as part of running reverse engineer.
    • The reverse engineer process by default produces a complete mapping using the fluent API. Items such as column name will always be configured, even when they would be correctly inferred by conventions. This allows you to refactor property/class names etc. without needing to manually update the mapping.
      • The Customize Reverse Engineer Templates command (see below) lets you customize how code is generated.
    • A connection string is added to the App/Web.config file and is used by the context at runtime. If you are reverse engineering to a class library, you will need to copy this connection string to the configuration file of the consuming application(s).
    • This process is designed to help with the initial coding of a Code First model. You may need to adjust the generated code if you have a complex database schema or are using advanced database features.
    • Running this command multiple times will overwrite any previously generated files, including any changes that have been made to generated files.
  • Customize Reverse Engineer Templates 
    Adds the default reverse engineer T4 templates to your project for editing. After updating these files, run the Reverse Engineer Code First command again to reverse engineer POCO classes, a derived DbContext, and Code First mappings using your project's customized templates.
    • The templates are added to your project under the CodeTemplates\ReverseEngineerCodeFirst folder.

When right-clicking on a code file containing a derived DbContext class

  • View Entity Data Model (Read-only)  
    Displays the Code First model in the Entity Framework designer.
    • This is a read-only representation of the model; you cannot update the Code First model using the designer.
  • View Entity Data Model XML 
    Displays the EDMX XML representing the Code First model.
  • View Entity Data Model DDL SQL 
    Displays the DDL SQL to create the database targeted by the Code First model.
  • Generate Views 
    Generates pre-compiled views used by the EF runtime to improve start-up performance. Adds the generated views file to the containing project.
    • View compilation is discussed in the Performance Considerations article on MSDN.
    • If you change your model then you will need to re-generate the pre-compiled views by running this command again.

When right-clicking on an Entity Data Model (*.edmx) file

  • Generate Views 
    This is the same as the Generate Views command above except that, instead of generating pre-compiled views for a Code First model, it generates them for a model created using the EF Designer.

Comments

  • Anonymous
    January 30, 2013
    I was so happy when I saw the title.... but no new features =/ I am waiting long time to have a Enterprise class tool to use Code-First with existing database

  • Anonymous
    January 30, 2013
    @Felipe - The reason we aren't adding a bunch of new features is that we're incorporating 'Reverse Engineer Code First' into the EF Designer workflow (which already has table selection etc.). More details about this work here - entityframework.codeplex.com/wikipage.

  • Anonymous
    January 30, 2013
    So, Code First doesn't use a designer. From a Code First perspective, the most interesting bit is Reverse Engineer Code First, which also doesn't need the designer. It's an interesting release dependency. As a side note, Code First doesn't seem to be a great name for the code-centric approach...

  • Anonymous
    January 30, 2013
    The comment has been removed

  • Anonymous
    January 30, 2013
    I was hoping the "Sequence contains no matching element" error would be fixed but it's still there when using the "Generate Views" menu.

  • Anonymous
    January 31, 2013
    @Naz - We fixed one bug that was causing "Sequence contains no matching element" errors -  entityframework.codeplex.com/.../214 . If you are still seeing this error it's probably a bug that we aren't aware of - could you file an issue on our CodePlex site with details of your project setup etc. entityframework.codeplex.com/.../Create .

  • Anonymous
    February 06, 2013
    I'm also getting the "Sequence contains no matching element" error when selecting any of the items (haven't had this installed before at all). Will try it with a new project rather than our solution with 12 projects in it already to see if it works at all.

  • Anonymous
    February 06, 2013
    I've found an... 'mistake' that the Reverse Engineer Code First have commited, he is changing the order of primary keys in the code mapping that leads an cascade error in the foreign keys mapping in the child tables. I don't know if this ocurring only with me, because my database has a schema very full of keys and foreign keys, does anybody notes that?

  • Anonymous
    February 06, 2013
    Edit: "does anybody notes that behavior in the key mapping"?

  • Anonymous
    February 07, 2013
    The comment has been removed

  • Anonymous
    February 07, 2013
    @Matheus Vieira - Can you open an issue with an example of some tables and the incorrect code that is generated from them? entityframework.codeplex.com/.../Create

  • Anonymous
    February 09, 2013
    I have received "sequence contains no matching element " with EF4.3 in .net4.0. my context derived directly from DbContext and I have default constructor.

  • Anonymous
    February 12, 2013
    There is an error in EF 6 Alpha 2. when i want to use any method of EntityFunctions class (such as Right), i get the following error: LINQ to Entities does not recognize the method 'System.String Right(System.String, System.Nullable`1[System.Int64])' method, and this method cannot be translated into a store expression. Sample code: using (var context = new AdventureWorks2012Entities()) {    var contacts = from c in context.Products                   where EntityFunctions.Right(c.Name, 2) == "HH"                   select c;    foreach (var item in contacts)    {        MessageBox.Show(item.Name);    } }

  • Anonymous
    February 13, 2013
    For the wrong key mapping, i've created the issue: entityframework.codeplex.com/.../868

  • Anonymous
    February 22, 2013
    @beh - In EF6 Alpha 2 you want to use DbFunctions, it looks like you are still using the EntityFunctions type from System.Data.Entity.dll in the .NET Framework (I would recommend removing this reference). Here is more info on moving to EF6 - entityframework.codeplex.com/wikipage BTW we agree the rename of EntityFunctions => DbFunctions is confusing and we are considering renaming it back - entityframework.codeplex.com/.../832

  • Anonymous
    February 22, 2013
    @Mehran - If you can provide a project that reproduces the issue, it would be great if you could open an issue on our CodePlex site and attach it - entityframework.codeplex.com/.../Create

  • Anonymous
    February 22, 2013
    @Matheus Vieira - Thanks, we've looked at the issue and we're going to try and fix it in EF6.

  • Anonymous
    March 04, 2013
    Is there a way to auto-generate the pre-compiled views since this feature is really amazing. Nevertheless, repeating this step by hand is really annoying!

  • Anonymous
    March 05, 2013
    @Uli - There is information about using a T4 template to auto generate views here - blog.3d-logic.com/.../entity-framework-6-and-pre-generated-views.

  • Anonymous
    April 09, 2013
    I think it would be a nice idea, on right-clicking on a code file containing a derived DbContext class, or on an Entity Data Model (*.edmx) file, to exist an option to create metadata classes...

  • Anonymous
    April 10, 2013
    @George J. Capnias - Can you expand on what you mean by 'metadata classes'?

  • Anonymous
    April 10, 2013
    @Rowan Miller In order to control validation, display names, etc., one has take advantage of DataAnnotations. For each class/entity, a new partial class has to be created, with an embedded "metaclass". The whole process could be done by right-clicking on a code file containing a derived DbContext class, or on an Entity Data Model (*.edmx) file, to exist an option to create metadata classes...

  • Anonymous
    April 12, 2013
    @George J. Capnias - It's an interesting idea, I'm not sure how many folks would want to use it (I suspect most people would want to just hand code classes for the entities they want to have buddy classes for). Feel free to add a feature request on out CodePlex site - entityframework.codeplex.com/.../Create. It's not something we'd look at in EF6 but if we saw significant demand for it we could consider it in the future.

  • Anonymous
    May 27, 2013
    Hi There, I am using Visual Studio 2012, I have tried all the work arounds listed above and also that I could find via search engines. I have to my knowledge all the updates to vs and power tools. None of my context menu items work. this is quite frustrating as management is constantly asking me for update on our ERD. To create this I have to first change out my connection strings, let my program create the database, then start up a new solution and use the Ado.Net Entity Data Model to reverse engineer the database and then from that start moving things around so that I can provide them with the updated ERD. We are busy with a massive re-write and this primarily based upon EF code first. When can we expect a solution to this linger problem which is clearly hassling a lot of fellow developers our there?

  • Anonymous
    May 28, 2013
    @Louis Lewis, you can write an EDMX file from code via the following. using (var db = new MyContext()) using (var writer = XmlWriter.Create("MyContext.edmx")) {    EdmxWriter.WriteEdmx(db, writer); }

  • Anonymous
    June 19, 2013
    Still get "sequence contains no elements" when trying to generate views. Followed all the advice on forums but still get stupid error.

  • Anonymous
    June 21, 2013
    @Ben - A lot of folks are hitting the various issues with the Power Tools. We're going to spend some time making them more robust but we're spending time on a bug fixing push on EF6 before we do that.

  • Anonymous
    July 14, 2013
    The previous version was much better.. Seems like a few people like the partial classes for entities but i bet the majority does not. Also it seems like this version did away with creating singular named entities. When using the reverse engineer with this version I have a great deal more work making changes to the generated code than in the previous version.

  • Anonymous
    July 22, 2013
    @JBecktonicus - You can always customize things such as this by editing the templates used for code generation (saves you having to edit the classes once they are generated) - romiller.com/.../customizing-reverse-engineer-code-first-in-the-ef-power-tools.

  • Anonymous
    August 08, 2013
    Does not work with Oracle!

  • Anonymous
    August 26, 2013
    if a field is numeric(13,6), you cannot get a numer like 123.6689(only 123.67)

  • Anonymous
    September 05, 2013
    I can't get this to work with Oracle either.  I've seen some posts on stackoverflow suggesting that it's possible, but I'm not sure how to do this.  It will create one single Context object (below) and the app.config, but nothing else.  Looks like it's not recognizing any tables. public partial class Context : DbContext    {        static Context()        {            Database.SetInitializer<Context>(null);        }        public Context()            : base("Name=Context")        {        }        protected override void OnModelCreating(DbModelBuilder modelBuilder)        {        }    }

  • Anonymous
    September 06, 2013
    @eschneider8888 & @Ed May - We're going to be updating the Power Tools to work with EF6 before the RTM of EF6. We'll try and take a look at this issue at the same time.