Sdílet prostřednictvím


EF6 Alpha 2 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.


 

Around a month ago we released the first alpha of EF6. Today we are pleased to announce that availability of Alpha 2. 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 2 are likely to change significantly 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 2

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 1

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

  • 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. 
  • Custom Code First Conventions have evolved significantly since Alpha 1 based on your feedback and further design. We have updated the walkthough for this feature and the feature specification on our CodePlex site. 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.
  • 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.

What Else is New in EF6

The following features are included in Alpha 2 but have not changed significantly since Alpha 1:

  • Async Query and Save - EF6 now supports 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.
  • Multiple Contexts per Database (Formerly known as 'Multi-Tenant Migrations') - 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.
  • 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.
  • 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.
  • Dependency Resolution - EF now supports 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.
  • 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.

 

What's after Alpha 2

Our  Roadmap provides details of all the features we are planning to implement in EF6, including the features we haven't started yet. If you want to try out the changes we've made since the last official pre-release, you can use the latest signed nightly build. You can also check out the Feature Specifications page on CodePlex for more information about new features that we are working on. You can also read our Design Meeting Notes to keep track of the evolving design of new features.

Comments

  • Anonymous
    December 12, 2012
    Is there any way to use enums with .NET 4.0 when using model-first approach? The "Convert to enum" option does not seem to be available, which I suppose is due to Edmx version being 2.0 (and 3.0 seems to only be supported in .NET 4.5).

  • Anonymous
    December 13, 2012
    The comment has been removed

  • Anonymous
    December 13, 2012
    The comment has been removed

  • Anonymous
    December 13, 2012
    @Jon: Alpha2 does require MARS or LazyLoading will not work. However take a look at this checkin from yesterday: entityframework.codeplex.com/.../22ed3cab3f43

  • Anonymous
    December 13, 2012
    @Pawel Kadluczka. We are using model-first approach because we are working on a large schema and we benefit greatly from the visual representation of the model. Another reason to go model-first is because we are doing some automatic code generation for e.g. cache classes using T4. That's why we need the edmx file currently. But maybe we could run T4 against our code-first classes to achieve same results?

  • Anonymous
    December 13, 2012
    "Another reason to go model-first is because we are doing some automatic code generation for e.g. cache classes using T4. That's why we need the edmx file currently. But maybe we could run T4 against our code-first classes to achieve same results?" Yes, this works. I also work this way. I use T4 Templates to generate POCOs and map them with the Fluent API based on the EDMX files. I've replaced the EntiyFrameworkTemplateFilemanager with a custom Manager and now I generate the mapping and context files into a new library and only have a library with POCOs and no references to EF.

  • Anonymous
    December 13, 2012
    Thank Pawel. Has anyone else noticed slow performance when MultipleActiveResultSets is enabled? I'm wondering why performance is so much worse when it's enabled?

  • Anonymous
    December 14, 2012
    @Jon - I don't know exact details on how is MARS implemented but I know MARS adds a lot of overhead. In some scenarios requests using MARS need to be synchronized and serialized which in turn may require bufferring responses to be able to handle the particular request. On the other hand - it would be interesting to understand why you are fetching 1.4 mln rows with EF - it does not feel right (at least when combined with EF) and there may be a better way to achieve what you want to achieve.

  • Anonymous
    December 15, 2012
    @John Arete - I actually tried Model/Database First approaches with EF6 and it turned out that it was not cumbersome at all. While this still is not a supported scenario you can give it try. I wrote a blog post on this: blog.3d-logic.com/.../entity-framework-6-and-modeldatabase-first

  • Anonymous
    December 17, 2012
    When would Entity Framework support Hierarchy Id? Please consider including it.

  • Anonymous
    December 17, 2012
    @HierarchyId Support Please Support for HierarchyId is not currently in the plan for EF6. I would encourage you to vote for it here: data.uservoice.com/.../1074177-support-for-hierachical-queries-and-hierarchyid Thanks, Arthur

  • Anonymous
    December 18, 2012
    Pawel, I'm developing a console application that transfers data from a database on one server to a different database on another server that is used for reporting. The application uses Entity Framework for the query and uses SqlBulkCopy for inserting rows on the other. However, I have other similar applications that may have complex update logic where I would like to use Entity Framework on the write side as well rather than SqlBulkCopy. I could use ADO.NET core for the query, but, I would rather use EF because it is more expressive and I like working in a more object oriented fashion. Query-wise, I don't think EF is that much worse than ADO.NET Core as long as you turn off MultipleActiveResultSets. I found that MARS slows down ADO.NET core by about the same amount. It's too bad EF can't be configured to use multiple connections or something to speed things up, because that's a pretty big performance hit IMHO. EF could use a lot of improvement on the update side of things as well. It seems that a lot of attention has been paid to improving query performance, but, I think it doesn't even use parameterized queries for updates. P.S. It would be great if Microsoft could fix the blog posting app so that it saves your comments correctly. If you let the page sit for too long, I think the session times out and your post won't go through. The session timeout seems to be set too low also.

  • Anonymous
    December 21, 2012
    @HierarchyId Support Please I have added the hierarchyid support to my fork of EF. If you need it, and it is not a problem for you to compile your own EF then you can check my changes: entityframework.codeplex.com/.../eb8443fea39f

  • Anonymous
    December 28, 2012
    Hi mr Miler. Thanks a lot for the release. That's a good job you have :) I love that ! Could i ask you for the time that Function Import inclution in the Code First in EF6 Release ? The feature is not included yet, and we don't find a way to implement that using Code First. Thanks Massoud Safari.

  • Anonymous
    December 31, 2012
    @Massoud Safari We have somebody who is just starting on the work for mapping to stored procs and using function imports in Code First and it is still planned to be in the EF6 release. We don't have any public dates yet for when the final (RTM) EF6 release will happen, but you can expect continued pre-release versions (alpha/beta/RC) in the coming months and the plan is for those releases to start including this work. Thanks, Arthur

  • Anonymous
    January 03, 2013
    Often I want to get an Entity back from the database, but would like to skip grabbing a large binary field. Will EF 6.0 supply any sort of .Exclude("Entity.ColumnName") extension method, or some other mechanism to handle this usecase?

  • Anonymous
    January 03, 2013
    The comment has been removed

  • Anonymous
    January 04, 2013
    @Jon Reis: Just to add to what Arthur said: EF also supports a feature called "table splitting" which can be handy for this scenario. You basically create two entities with a one-to-one relationship that are mapped to the same table. The principal entity maps to most of the data in the table and the dependent entity only maps to the key and the binary column. Now when you query for the principal entity you don't get the contents of the binary column loaded but if you navigate to the dependent entity lazy loading will take care of loading it from the database. See  msdn.microsoft.com/.../jj715645 for an example of how to do it with the designer, and stackoverflow.com/.../how-to-map-table-splitting-in-ef-code-first for an example of how to do it with Code First.

  • Anonymous
    January 07, 2013
    It is listed in the planned features for EF 6 that it will provide support for stored procedures & functions in code first. Is there any dates of when will this feature be available even in alpha release?? It is a very important feature and we've been waiting about one year for it. Thank you.

  • Anonymous
    January 07, 2013
    @"SPROC & TVF Support Please" We have somebody who is just starting on the work for mapping to stored procs and using function imports in Code First and it is still planned to be in the EF6 release. We don't have any public dates yet for when the final (RTM) EF6 release will happen, but you can expect continued pre-release versions (alpha/beta/RC) in the coming months and the plan is for those releases to start including this work. Also, the features will start showing up in nightly builds as soon as they are checked in so you may want to keep track of the latest checkins on the CodePlex site. Thanks, Arthur

  • Anonymous
    January 07, 2013
    It really seems that Entity Framework is heading in the right direction. Glad to see that :) Any plan to compare improved performance to something like NHibernate? There are many candidates like LINQ performance, and startup / generation of mappings

  • Anonymous
    February 15, 2013
    The comment has been removed

  • Anonymous
    February 20, 2013
    @Mohamed Meligy - Our team isn't planning to put together the comparison. In the past a number of folks out side of Microsoft have put together good comparisons.

  • Anonymous
    February 20, 2013
    @shashi  - Looks like it's an issue with our install script handling F# projects. I've opened a CodePlex work item to track the issue - entityframework.codeplex.com/.../891

  • Anonymous
    March 27, 2013
    Hello.  I'd like to be able to use the visual designer for my tables in VS.  I'd then like that model to stay synched with the database withOUT losing data.  Without this ability, the designer becomes fairly useless and one is left with "code first" mostly.  Telerik's OpenAccess handles this without a hitch... couldn't Microsoft tackle it too?  :-)

  • Anonymous
    March 27, 2013
    @Donna - It's not something that we can fit into EF6, but we are planning to enable migrations for the EF Designer in the future. You can vote on the feature here - entityframework.codeplex.com/.../89

  • Anonymous
    January 08, 2014
    can Entity Framework 6 support to Oracle database.. Thanks

  • Anonymous
    January 09, 2014
    @Ankush - Devart has an EF6 provider that works with Oracle - www.devart.com/dotconnect