Partilhar via


EF6 Alpha 3 Available on NuGet

 


The information in this post is out of date.

EF6 RTM is now available.

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


 

A couple of months back we released EF6 Alpha 2, since then we've been adding new features, polishing existing features and fixing bugs. Today we are pleased to announce the availability of Alpha 3. EF6 is being developed in an open source code base on CodePlex, see our open source announcement for more details.

 

We Want Your Feedback

You can help us make EF6 a great release by providing feedback and suggestions. You can provide feedback by commenting on this post, commenting on the feature specifications linked below or starting a discussion on our CodePlex site.

 

Support

This is a preview of features that will be available in future releases and is designed to allow you to provide feedback on the design of these features. It is not intended or licensed for use in production. The APIs and functionality included in Alpha 3 are likely to change prior to the final release of EF6.

If you need assistance using the new features, please post questions on Stack Overflow using the entity-framework tag.

 

Getting Started with Alpha 3

The Get It page provides instructions for installing the latest pre-release version of Entity Framework.

Note: In some cases you may need to update your EF5 code to work with EF6, see Updating Applications to use EF6.

 

What's Changed Since Alpha 2

The following features and changes have been implemented since Alpha 2:

  • Code First Mapping to Insert/Update/Delete Stored Procedures is now supported. The feature specification on our CodePlex site provides examples of using this new feature. This feature is still being implemented and does not include full Migrations support in Alpha 3.
  • Connection Resiliency enables automatic recovery from transient connection failures. The feature specification on our CodePlex site shows how to enable this feature and how to create your own retry policies.
  • We accepted a pull request from iceclow that allows you to create custom migrations operations and process them in a custom migrations SQL generator. This blog post provides an example of using this new feature.
  • We accepted a pull request from UnaiZorrilla to provide a pluggable pluralization & singularization service.
  • The new DbContext.Database.UseTransaction and DbContext.Database.BeginTransaction APIs enable scenarios where you need to manage your own transactions.

What Else is New in EF6

The following features and changes are included in Alpha 3 but have not changed significantly since Alpha 2:

  • Async Query and Save adds support for the task-based asynchronous patterns that were introduced in .NET 4.5. We've put together a walkthrough that demonstrates this new feature. You can also view the feature specification on our CodePlex site for more detailed information.
  • Custom Code First Conventions allow write your own conventions to help avoid repetitive configuration. We provide a simple API for lightweight conventions as well as some more complex building blocks to allow you to author more complicated conventions. We have a walkthough for this feature and the feature specification is on our CodePlex site.
  • Dependency Resolution introduces support for the Service Locator pattern and we've factored out some pieces of functionality that can be replaced with custom implementations. The feature specification provides details about this pattern, and we've put together a list of services that can be injected.
  • Code-Based Configuration - Configuration has traditionally been specified in a config file, EF6 also gives you the option of performing configuration in code. We've put together an overview with some examples and there is a feature specification with more details.
  • Configurable Migrations History Table - Some database providers require the appropriate data types etc. to be specified for the Migrations History table to work correctly. The feature specification provides details about how to do this in EF6.
  • Multiple Contexts per Database - In previous versions of EF you were limited to one Code First model per database when using Migrations or when Code First automatically created the database for you, this limitation is now removed. If you want to know more about how we enabled this, check out the feature specification on CodePlex.
  • Updated Provider Model - In previous versions of EF some of the core components were a part of the .NET Framework. In EF6 we've moved all these components into our NuGet package, allowing us to develop and deliver more features in a shorter time frame. This move required some changes to our provider model. We've created a document that details the changes required by providers to support EF6, and provided a list of providers that we are aware of with EF6 support.
  • Enums, Spatial and Better Performance on .NET 4.0 - By moving the core components that used to be in the .NET Framework into the EF NuGet package we are now able to offer enum support, spatial data types and the performance improvements from EF5 on .NET 4.0.
  • DbContext can now be created with a DbConnection that is already opened. Find out more about this change on the related work item on our CodePlex site.
  • Improved performance of Enumerable.Contains in LINQ queries. Find out more about this change on the related work item on our CodePlex site.
  • Default transaction isolation level is changed to READ_COMMITTED_SNAPSHOT for databases created using Code First, potentially allowing for more scalability and fewer deadlocks. Find out more about this change on the related work item on our CodePlex site.
  • We accepted a pull request from AlirezaHaghshenas that provides significantly improved warm up time (view generation), especially for large models. View the discussion about this change on our CodePlex site for more information. We're also working on some other changes to further improve warm up time.
  • We accepted a pull request from UnaiZorrilla that adds a DbModelBuilder.Configurations.AddFromAssembly method. If you are using configuration classes with the Code First Fluent API, this method allows you to easily add all configuration classes defined in an assembly. 

 

What's after Alpha 3

Alpha 3 contains all the major features we are planning to implement for the runtime in the EF6 release. We'll now turn our attention to polishing and completing these new features, implementing small improvements, fixing bugs and everything else to make EF6 a great release. We're still accepting pull requests too.

We've also been getting the EF Designer code base updated for the EF6 release and we hope to have a preview of the EF6 designer available soon.

If you want to try out changes we've made since the last official pre-release, you can use the latest signed nightly build. You can also check out our Feature Specifications and Design Meeting Notes to stay up to date with what our team is working on.

Comments

  • Anonymous
    February 27, 2013
    Congrats, You guys are a fantastic team. Unai

  • Anonymous
    February 27, 2013
    And as for this bug has been resolved: Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries.

  • Anonymous
    February 27, 2013
    "Alpha 3 contains all the major features we are planning to implement for the runtime in the EF6 release" Dies this mean there is no code first support for stored procedures and tvf as specified in the roadmap?

  • Anonymous
    February 27, 2013
    I just see, you removed the entries from the road map in the newest version. Too bad, that's the feature I wait most for, because without it I won't be able to introduce code first here. :-

  • Anonymous
    February 27, 2013
    Nice work, but there is no simple solution for bulk insert. I use entity framework to read data, and write small things. But to insert more data i use binding query... and i loose a part of the power of entity framework (detach, attach is a bit borring)

  • Anonymous
    February 28, 2013
    The comment has been removed

  • Anonymous
    February 28, 2013
    @dfiad77pro - We have a couple of features that we want to implement (though not in the EF6 release) around batch operations.

  • Batching up insert/update/delete operations rather than sending individual commands entityframework.codeplex.com/.../53
  • Bulk/set operations without loading data from the database entityframework.codeplex.com/.../52 Please add your votes to those... and feel free to comment with any scenarios we should take into account when we get to the features.
  • Anonymous
    February 28, 2013
    Great progress. However, (and I don't mean to sound like an ingrate...BUT...) support for arbitrary stored procedures is really important and it is a huge disappointment to see that it didn't make it in.

  • Anonymous
    February 28, 2013
    I'm also disappointed that function imports has been cancelled. Anyway I like the EF Code-First approach.

  • Anonymous
    February 28, 2013
    Rowan, Is there any solution for this? Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries.

  • Anonymous
    February 28, 2013
    @CraigAJohnson & @ben - We are still trying to squeeze support in, but it's not a definite for EF6. One of the things that makes it lower priority is how easy it is to do with SqlQuery - db.Blogs.SqlQuery("dbo.GetBlogsWithTag @p0", "entity-framework").

  • Anonymous
    February 28, 2013
    @Veranildo Veras - There are many scenarios that can cause this error, if you are seeing it in a situation that you didn't in earlier versions of EF (or a situation that it shouldn't be occurring) can you file a new issue - entityframework.codeplex.com/.../Create. Be sure to include a code sample that reproduces the issue.

  • Anonymous
    February 28, 2013
    @Rowan Miller - thanks for the answer! Yes, stored procedures are no problems to integrate, but TVF (e.g. fulltext search) is ugly to write in raw sql where there are many conditional fiters. // Filter example: if (countryId.HasValue)  query = query.Where(x => x.CountryId= countryId); if (categoryId.HasValue)  query = query.Where(x => x.CategoryId = categoryId); if (query != null) {    query = from x in MyDbContext.ContainsTableWrapper(query)                  join y in query on x.Key equals y.Key                  select y; } // And so on....

  • Anonymous
    February 28, 2013
    Does anyone know if there are plans to improve insert/update performance? I noticed that EF seems to not use prepared commands for inserts/updates. This surprised me. I think this would help a lot with regard to bulk insert/update speed. It would also be great if there was a way to clear the DbContext of items to keep memory usage down.

  • Anonymous
    February 28, 2013
    What happens to System.Data.Entity.Design assembly? How is it going to get released from now on? I'm asking this because we build custom a model generator based on the design assemblies and we cannot migrate until they are in sync.

  • Anonymous
    February 28, 2013
    @Rowan Thank you for your response. :-) I'm looking forward to your progress. Keep up the good work!

  • Anonymous
    February 28, 2013
    Thanks for the great work you are doing! One of the biggest problem we have right now is the startup time with a big model: 1100+ tables. With EF 6 aplha 2 the first query is taking about 25 sec. This is a great improvement over EF5 where without pre-generated views takes a lot more (tens of minutes!). However it would be nice if EF6 offered API for pre-generated views. Any future plans on this? It would greatly reduce those 25 sec on startup. With EF 5 we are generating the views using Stystem.Data.Entity.Design/EntityViewGenerator class which calls System.Data.Entity.dll/System.Data.Mapping.StorageMappingItemCollection <== this was now improved and moved to EF 6. This means that EntityViewGenerator can no longer be used for EF6. What would be nice is to also "move" the generators from Stystem.Data.Entity.Design to EF. Thanks again!

  • Anonymous
    March 01, 2013
    @Osu - we have a work item for adding support for generating views entityframework.codeplex.com/.../369. We also have discussed this at our design meeting - you can find notes here: entityframework.codeplex.com/wikipage. I also created a T4 template for generating views for EF6 - you can find my blog post here: blog.3d-logic.com/.../entity-framework-6-and-pre-generated-views. The template is on VS Gallery (note I created it for EF6 Alpha1 and have not tried it with EF6 Alpha3 but hopefully it will work)

  • Anonymous
    March 01, 2013
    @Catalin Pop - We aren't planning to move System.Data.Entity.Design into the out-of-band releases (the EF5 version will remain in the framework though). We are moving over bits of the functionality from System.Data.Entity.Design into EF6 so it would be great to here more about you scenario and which APIs you are using. You can either reply here or start a discussion on our CodePlex site - entityframework.codeplex.com/.../create.

  • Anonymous
    March 01, 2013
    @ben - You are right, TVFs are pretty ugly. We'll try and get support into EF6 (but we aren't definitely committed to it).

  • Anonymous
    March 01, 2013
    @Jon - We don't have any major improvements planned for EF6. We have talked about prepared commands before but we didn't have an item tracking it on CodePlex, so I created one - entityframework.codeplex.com/.../912. We also have a post-EF6 item to look at batching up statements during SaveChanges.

  • Anonymous
    March 04, 2013
    Hi mr Miller. I appreciate you for the release :) For the comment that you noticed for how to implement EF TVF usage in code-first, i don't actually have an idea how to implement a Fully Linq-Enabled, Queryable (and/or Queryable<T>) implementation with SqlQuery<T>. we need a Queryable<T> method to call our TVfs and need to pass parameters to those. even, imagine if we could define a SelectSource and a TableSource for a POCO object in the [Table] attribute above that POCO, to distinguish between the physical source and View source of the POCO. this will make object-population (materialization) very flexible and we also could define some POCO fields as Databse Generated, so that they are populated from View-Like queries. i mean fileds that are populated from fields in the query (or view) that are retrived via a join operetion in the view/TVF. I ensure This will have an impressive, and will soon be a developer-popular feature that whould never be in any other ORMs :) Who will be better than EF, but EF ?!  ;) we are waiting for EF6, and we are counting for the features (or at least TVFs with Full Linq and Queryable support) i mentioned. Thanks a lot mr Miller. Thanks for your support (Y) Massoud Safari

  • Anonymous
    March 04, 2013
    @Rowan Thanks for creating the issue for prepared commands. I have seen the issue for batching previously. I was surprised that people were looking into that without first looking into prepared commands. It seems like prepared commands would be an obvious way to improve performance and easier to implement. It seems like there really needs to be a way of clearing the tracked objects as well. The only way I'm aware of to do this is create a new DbContext which seems to have a lot of overhead.

  • Anonymous
    March 04, 2013
    @Jon: We have been working on the problem you mentioned about the costs associated to create a new instance of DbContext. This improvement will be present in future versions of EF6, but it didn't make it in time for the alpha 3 build. You'll see a much lighter DbContext initialization time if you use the nightly build or the latest code from our git repository. For more details about this performance improvement refer to entityframework.codeplex.com/.../828.

  • Anonymous
    March 04, 2013
    You can implement the WhereOr for building dynamc query white EF6. PLEASE !

  • Anonymous
    March 05, 2013
    @SeniorSafari - Being able to compose a query on the results of a TVF isn't supported by SqlQuery. The feature you are after is entityframework.codeplex.com/.../818 which we are going to try and get into EF6 (but it's not a definite at this stage).

  • Anonymous
    March 05, 2013
    @neoncyber - Could you provide some more information about the feature you are after. An example of the query you would like to write would be ideal.

  • Anonymous
    March 05, 2013
    Thanks mr Miller for the response to my comment. I hope the feature will be added in the next release of EF6. Sincerely SeniorSafari

  • Anonymous
    March 05, 2013
    The comment has been removed

  • Anonymous
    March 07, 2013
    @neoncyber - As you mentioned there are a few frameworks that help you build an expression that can be passed into the Where clause. Some folks on our team have thought about what something like this might look like built into EF. However, at this stage it's a lower priority because there are existing frameworks that will help you do it.

  • Anonymous
    March 11, 2013
    @Rowan Miller To answer your question regarding System.Data.Entity.Design, our scenario is the following: Environment:

  • 1800+ Tables
  • 20+ Schemas
  • 3200+ Foreign Keys (Cross Schema) (We can't use the designer due to sheer number of entities. As to why they are so many of them it's a separate discussion, but the simple explanation is that the business domain model is uncommonly large when modeled using 3NF) Model Generation process:
  • Use EntityStoreSchemaGenerator to generate SSDL
  • Use EntityModelSchemaGenerator to generate CSDL
  • Generate Mappings (MSL)
  • Save EDMX in memory buffer.
  • Read Metadata for entire Database model from a separate database
  • Load the EDMX in a custom class model and rewrite it to achive the following:      - Remove a set of excluded columns (exluded using Metadata)      - Remove all undesired OneToMany relationships (based on Metadata; avoids having thousand of unwanted member collections in the generated code, IE all tables have foreign keys to the User table: remove all reverse relationships from user to all tables in the system as they are not needed and add a heavy performance tax when loading a related user)      - Rename navigation members based on foreign key name (IE: for Parent_ID: Person1 to Parent, for Neighbor_ID: Person2 to Neighbor, etc.)      - Perform other renames in the model (metadata driven)      - Mark entities with EDM metadata specifying what interfaces should be added by code generator to entities, IE: IEntity(ID,Name), IAuditable(InsertDate, EditDate, InsertUser_ID, EditUser_ID), ILifeCycle(LifceCycle_ID), etc...      - Add EDM metadata to entities and properties for a set of validation attributes to be added to the model (IE: Readonly, Required, StringLenght, DisplayName, Visibility, UniqueConstraint, and many more very specific)
  • Save modified EDMX.
  • Generate C# classes for entities and 6 different contexts using a T4 generator.
  • Generate pregenerated views using EntityViewGenerator. Our biggest problems are:
  • CSDL generation takes about 30 minutes;
  • Creating Pregenerated Views takes about 45 minutes (post model cleaning, much more if all the relationships are kept). Therefore until we will be able to programatically manipulate the EDMX and generate pregenerated views we cannot take full advantage of EF6 improvements. With kind regards, Catalin Pop
  • Anonymous
    March 11, 2013
    @David Thanks for the info. On an unrelated note, I noticed that EF now automatically creates indexes on foreign keys. Thanks for that. From what I remember, it didn't do that originally. It's nice to have those created automatically.

  • Anonymous
    March 11, 2013
    "CSDL generation takes about 30 minutes;" Correction SSDL generation takes about 30 minutes. Catalin Pop

  • Anonymous
    March 12, 2013
    The comment has been removed

  • Anonymous
    March 13, 2013
    @Osu: there is a known performance issue with the alpha 3 release of EF6, as documented in entityframework.codeplex.com/.../902. The issue has been resolved and some additional improvements have been added to EF6 after the alpha 3 build was released. Would it be possible for you to grab a nightly build and run your tests again? I'm curious to see if the performance issue persists, or if it is something we missed. You can get the nightly build by following these instructions: entityframework.codeplex.com/wikipage

  • Anonymous
    March 13, 2013
    @Osu: Glad to hear that view gen templatate works with EF Alpha3. Thanks!

  • Anonymous
    March 15, 2013
    Hi, a lack of functionality in CodeFest FileTable or FileStream a new version of EntityFramework 6

  • Anonymous
    March 19, 2013
    Hello, There seems to be a major bug in EF6 alpha that is not present in EF5. On short: Inner join generated where an outer join is expected. This happens when a join is made from T1 to T2 and then to T3 if the relation T1-T2 is optional but T2-T3 is mandatory. More details here: entityframework.codeplex.com/.../960 This is currently keeping us from adopting EF6. Any chances of having this fixed soon? Thanks!

  • Anonymous
    March 19, 2013
    @Osu: thanks for bringing the issue to our attention. We are investigating.

  • Anonymous
    March 20, 2013
    Loving the update so far as we've had some pretty brutal speed issues in EF 4.1 on .Net 4.0.  I can't migrate the project to .Net 4.5 yet so I was excited when I saw that EF 6 added support for .Net 4.0.  This might seem like a goofy question, but how does one go about adding enums to a model-first designer that was created in an old version of EF?  I'd really prefer NOT to redo the entire EDMX as we modified objects to be better worded than the original underlying database tables; including primary keys.  We have several templates built off these modifications and with a large number of tables it would be time consuming to update all of these with a new EDMX.  Is it possible to add enums to existing EDMX files through the designer?

  • Anonymous
    March 20, 2013
    I should also mention that I'm still in VS 2010.

  • Anonymous
    March 20, 2013
    @Ryan H. EF6 does support all 3 schema versions supported by previous versions of EF. So you should be able to use your edmx file without changes. However if you generate code from your edmx this code won't work with EF6 without changes. Also, note that the designer in VS2010 did not support v3 schema so you won't be able to add enums using VS2010. (The designer in VS2010 supported only schema versions v2 and v1 while enums where introduced in v3). If you want enums on .NET Framework 4 in an existing edmx file you would need to update your edmx to v3 of the schema. You can do it manually by changing xml namespaces or you could try using VS2012 to do it for you (you would have to create a project targeting .NET Framework 4.5 and add the edmx file to the project and then the designer should give you the option to move to v3 (btw. v3 is backwards compatible with v2)). Unfortunately the designer in VS2012 does not support EF6. While you can somehow make it work (I blogged about this here blog.3d-logic.com/.../entity-framework-6-and-modeldatabase-first) it will probably not work for projects targeting .NET Framework 4. This means that in most cases you would have to edit your edmx separately from your project (or even manually) but then you may have problems with making all the customizations you have work. Just to let you know - we are working on a new version of the designer that will support EF6 which should solve these problems. Stay tuned.

  • Anonymous
    March 21, 2013
    @Catalin Pop Sever - For EF6 you will continue to be able to use the version of System.Data.Entity.Design that was included in .NET 4.5. This works because we haven't had to make and changes to the EDMX format to support new features.

  • Anonymous
    March 21, 2013
    The comment has been removed

  • Anonymous
    March 22, 2013
    and to this date still no built in second level caching ...

  • Anonymous
    May 24, 2013
    SOS There is a bug in this version: Enum field types are being duplicated with a '1' after the original field name ! what should I do?!?

  • Anonymous
    May 25, 2013
    @Arash Masir: Can you create an issue on the Entity Framework codeplex site: entityframework.codeplex.com ? Make sure to provide a repro.