Partager via


EF6 Beta 1 Available

 


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.


 

Since releasing Alpha 3 a few months ago, we've been working hard to add the remaining new features to the EF6 runtime and get the EF tooling ready to preview. Today we are pleased to announce the availability of EF6 Beta 1.

 

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 Beta 1 are likely to change as we polish the product ready for 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 Beta 1

The runtime is available on NuGet. If you are using Code First then there is no need to install the tooling. Follow the instructions on our Get It page for installing the latest pre-release version of Entity Framework.

The tooling is available on the Microsoft Download Center and will work with Visual Studio 2012. Install the tooling if you want to use Model First or Database First.

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

 

Things You Need to Know

EF6 Alpha 1-3 Migrations Must Be Recreated

Migrations created with earlier previews of EF6 will need to be recreated dueto some changes we made to the metadata stored in code behind. We realize that changes like this can be frustrating. One of the reasons we release early previews is to get your feedback and bug reports to help us make the final release great. Sometimes that means we need to make breaking changes between preview releases.

To recreate migrations, downgrade to the last migration created with EF5 or earlier, delete migrations from your Migrations folder that were created with EF6, then use Add-Migration to re-scaffold the changes you have made. If migrations are not re-created you will receive the following error when trying to add or apply migrations:

System.Data.Entity.Core.MappingException: Schema specified is not valid. Errors:
<File Unknown>(0,0) : error 2025: XML Schema validation failed for mapping schema. Schema Error Information : The 'https://schemas.microsoft.com/ado/2012/10/edm/migrations:IsSystem' attribute is not declared.

Uninstalling Beta 1 Tooling

When you install the Beta 1 tooling it will replace the EF Designer that was included in Visual Studio 2012. To revert back to the tooling that was included with Visual Studio 2012 follow these steps.

  1. Using Add/Remove Programs, uninstall Entity Framework Tools for Visual Studio 2012
  2. Repair your Visual Studio 2012 install

 

What's Changed Since Alpha 3

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

  • The EF tooling is included in this preview for the first time for the EF6 release. Our focus with the tooling has been on enabling EF6 support and enabling us to easily ship out-of-band between releases of Visual Studio. The tooling does not included any new features.
  • Code First Migrations now supports generating and altering stored procedures. The ability to map to stored procedures was introduced in Alpha 3.
  • Entity and complex types can now be nested inside classes.
  • DbSet.AddRange & RemoveRange provide a simple and efficient way to add or remove multiple entities.

 

What Else is New in EF6

The following features and changes were included in earlier previews of EF6.

  • Async Query and Save adds support for the task-based asynchronous patterns that were introduced in .NET 4.5. We've created a walkthrough and a feature specification for this feature.
  • 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’ve created a walkthough and a feature specification for this feature.
  • Code First Mapping to Insert/Update/Delete Stored Procedures is now supported. We’ve created a feature specification for this feature.
  • Connection Resiliency enables automatic recovery from transient connection failures. The feature specification shows how to enable this feature and how to create your own retry policies.
  • 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. We’ve created a feature specification and a list of services that can be injected.
  • Code-Based Configuration gives you the option of performing configuration – that was traditionally performed in a config file – in code. We've created an overview with some examples and a feature specification.
  • Configurable Migrations History Table allows you to customize the definition of the migrations history table. This is particularly useful for database providers that require the appropriate data types etc. to be specified for the Migrations History table to work correctly. We’ve created a feature specification for this feature.
  • Multiple Contexts per Database removes the previous limitation of one Code First model per database when using Migrations or when Code First automatically created the database for you. We’ve created a feature specification for this feature.
  • DbModelBuilder.HasDefaultSchema is a new Code First API that allows the default database schema for a Code First model to be configured in one place. Previously the Code First default schema was hard-coded to "dbo" and the only way to configure the schema to which a table belonged was via the ToTable API.
  • 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 which enables scenarios where it would be helpful if the connection could be open when creating the context (such as sharing a connection between components where you can not guarantee the state of the connection).
  • Default transaction isolation level is changed to READ_COMMITTED_SNAPSHOT for databases created using Code First, potentially allowing for more scalability and fewer deadlocks.
  • DbContext.Database.UseTransaction and DbContext.Database.BeginTransaction are new APIs that enable scenarios where you need to manage your own transactions.
  • Improved performance of Enumerable.Contains in LINQ queries.
  • Significantly improved warm up time (view generation) – especially for large models – as the result of a contribution from AlirezaHaghshenas
  • DbModelBuilder.Configurations.AddFromAssembly method was contributed by UnaiZorrilla. 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 Migrations Operations were enabled by a contribution from iceclow and this blog post provides an example of using this new feature.
  • Pluggable Pluralization & Singularization Service was contributed by UnaiZorrilla.
  • Improved Transaction Support updates the Entity Framework to provide support for a transaction external to the framework as well as improved ways of creating a transaction within the Framework. See this feature specification for details.

 

What's after Beta 1

Beta 1 contains all the features we are planning to implement for the EF6 release. We'll now be focusing on polishing and completing these features, fixing bugs and everything else to make EF6 a great release. We’ll still consider pull requests for the EF6 release but larger changes or ones that need significant testing will likely be moved to the following release.

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 or follow us on Twitter and Facebook to stay up to date with what our team is working on.

Comments

  • Anonymous
    May 30, 2013
    Great, I'll finally give a try. ;) Thank you guys, EF is becoming awesome!

  • Anonymous
    May 30, 2013
    Will EF 6 Code First support User Defined Functions? I think it's an important feature, because of some LINQ limitations. Thank you.

  • Anonymous
    May 30, 2013
    Did you forget to mention the new Interception API or does it not ship with this beta ?

  • Anonymous
    May 30, 2013
    The comment has been removed

  • Anonymous
    May 30, 2013
    Can the System.Spacial types like DbGeography be used in a Portable Class Library?

  • Anonymous
    May 30, 2013
    @dave: The beta only includes some of the initial infrastructure work we did for interception and hence we decided to leave it out of the announcement. In case you are interested, current nightly builds of EF6 contain a much more complete implementation of the feature, including the new simple logging API, as described in the feature specification located here: entityframework.codeplex.com/wikipage.

  • Anonymous
    May 30, 2013
    @Enrique Riego: Are you specifying that you want to download a preview version? You can do this by typing "Install-Package EntityFramework -Pre" in the Package Manager Console window. The link in the section on how to get the runtime contains complete instructions.

  • Anonymous
    May 30, 2013
    @Andy: EF spatial types currently only work with full .NET.

  • Anonymous
    May 30, 2013
    @Diego: Yes, I am writing 'Install-Package EntityFramework -Pre'

  • Anonymous
    May 30, 2013
    @Kim Tranjan: Code First (i.e. the approach that allows you to build an EF model using code) does not include API to declare or specify user-defined functions. That said, if your database or your model contain user-defined functions it is still possible to map those functions to methods in your application and then use those methods in LINQ queries. This works with both the DbContext and the older ObjectContext APIs. In EF6 we have defined a new attribute, System.Data.Entity.DbFunctionAttribute that supersedes the now obsolete EdmFunctionAttribute and can be used to decorate CLR methods in order to map them to user-defined functions. For more details, see  msdn.microsoft.com/.../system.data.objects.dataclasses.edmfunctionattribute.aspx. Hope this answers your question.

  • Anonymous
    May 30, 2013
    @Enrique Riego: not sure what could be the reason then. Others may have an idea, but feel free to file a bug at entityframework.codeplex.com/.../Create with more details about your configuration. Please include data like target framework, package source configuration, and the full output from the install-package command.

  • Anonymous
    May 30, 2013
    Does this version will support the second level caching ?

  • Anonymous
    May 31, 2013
    @diego is there a work around to allow entities to be in a PCL, which includes spatial properties, then use this PCL within a server .NET library with EF, and have spatial types in the resulting model/mapped database?

  • Anonymous
    May 31, 2013
    The comment has been removed

  • Anonymous
    May 31, 2013
    @Andy: Not sure this is exactly what you are looking for, but Rowan has an example in which he created DTO-like spatial types for the version of the entities that he uses in a Windows Store Application. These types are very simple POCO classes that just happen to have the same serialization format as DbGeography. The example is available in this blog post: romiller.com/.../build-2012-talk-video-and-source-code and is labeled ParkFinder.Desktop.

  • Anonymous
    May 31, 2013
    @Diege Have I understand that correct, that Code First has a way to implement UDF? blogs.msdn.com/.../ef6-beta-1-available.aspx Have you an example for UDF in Code First? This is an example for Database First: [EdmFunction("Model.Store", "ContainsTableWrapper")] public IQueryable<FulltextSearchResult> ContainsTableWrapper(string term) {    return CreateQuery<FulltextSearchResult>("[Model.Store].ContainsTableWrapper", new ObjectParameter[] { new ObjectParameter("Term", term) }); } var query = from x in MyDbContext.ContainsTableWrapper(term)                  join entity in query on x.Key equals entity.Id                  select entity; Thanks!

  • Anonymous
    May 31, 2013
    No real support for SQL Federations for this release I guess?

  • Anonymous
    June 02, 2013
    How to add new Web project ADO.NET Entity Framework 6 beta?

  • Anonymous
    June 02, 2013
    Great to see EF keeps evolving! But when will the top requested feature (entityframework.codeplex.com/.../57) be available?

  • Anonymous
    June 03, 2013
    Downloaded the source and it appears to be in System.Data.Entity.Core.Objects.Internal.BufferedDataReader:        private static ReaderMetadata ReadMetadata(string providerManifestToken, DbProviderServices providerSerivces, DbDataReader reader)        {            var fieldCount = reader.FieldCount;            var hasSpatialColumns = false;            DbSpatialDataReader spatialDataReader = null;            bool[] geographyColumns = null;            bool[] geometryColumns = null;            try            {                spatialDataReader = providerSerivces.GetSpatialDataReader(reader, providerManifestToken);                geographyColumns = new bool[fieldCount];                geometryColumns = new bool[fieldCount];            }            catch (ProviderIncompatibleException)            {            } ... The call to providerSerivces.GetSpatialDataReader (sic) always throws 'System.Data.Entity.Core.ProviderIncompatibleException'. As far as I can tell this is happening every query, rendering the debugging experience quite annoying.

  • Anonymous
    June 04, 2013
    SqlCe does not support geo spatial types so whenever you try using geo spatial types with Sql CE provider the provider throws because it does not know how to handle the type.

  • Anonymous
    June 04, 2013
    @Pawel thank you for replying - I am not using the spatial types but it is still catching the exception in the debug window many hundreds of times. I am happy to send a simple repro project if that is helpful.

  • Anonymous
    June 04, 2013
    Just installed Beta 1 and I get this error on build..: Error 1 The type or namespace name 'SqlAzureDbConfiguration' could not be found (are you missing a using directive or an assembly reference?)

  • Anonymous
    June 04, 2013
    @CraigAJohnson: do you by any chance have "breaking when exception is thrown" enabled? Go to Debug->Exception and see if the checkbox in the Thrown column for Common Language Runtime is checked. If it is and you don't need to break when exceptions are thrown you can uncheck it. Alternatively in the exception dialog you should have an option to ignore a given exception type by unchecking the "Break when this exception type is thrown" checkbox. It should be OK for ProviderIncompatibleException since in general you are not expected to see (let alone handle) this type of exception.

  • Anonymous
    June 05, 2013
    @Pawel I figured out how to stop seeing the messages - I right-clicked the Output window and unchecked "Exception Messages". From the EF source it looks like that logic is being refactored at the moment so I'll just watch for how it develops.

  • Anonymous
    June 05, 2013
    TUDO O QUE VCS FAZEM EU AMO DE PAIXÃO, SOU FÃ N 1 DA RÁDIO INCONFIDENCIA.

  • Anonymous
    June 05, 2013
    @Alex Dresko: 'SqlAzureDbConfiguration' was removed some time ago (see design notes at entityframework.codeplex.com/wikipage for the rationale). You explicitly configure EF to use SqlAzureExecutionStrategy like this: public class MyDbConfiguration : DbConfiguration {    public MyDbConfiguration()    {        AddExecutionStrategy(() => new  SqlAzureExecutionStrategy());    } }

  • Anonymous
    June 05, 2013
    @CraigAJohnson: Thanks for reporting the issue with the first chance exception. I have filed a bug for it: entityframework.codeplex.com/.../1225.

  • Anonymous
    June 05, 2013
    How do I test that SqlAzureExecutionStrategy is configured and working?

  • Anonymous
    June 08, 2013
    @DiegoBVega much appreciated, thanks. I'll watch the issue on CodePlex for any developments.

  • Anonymous
    June 08, 2013
    Hi Diego, We are using FluentAPI currently (thanks to PowerTools > Reverse Engineer Code First). We developed all our logic on top of that but we are still unable to access UDFs. I don't think that the DbFunctionAttribute is going to work with FluentAPI or Code First. Am I right? Thanks in advance

  • Anonymous
    June 09, 2013
    which changeset is the base for beta1? I want to compile it myself to debug it easier.

  • Anonymous
    June 10, 2013
    @Andre.Ziegler - There is a '6.0.0-beta1' tag that represents what we shipped for Beta 1.

  • Anonymous
    June 10, 2013
    The comment has been removed

  • Anonymous
    June 10, 2013
    @Eric - Nothing new in EF6 for federations, the guidance here still applies: msdn.microsoft.com/.../jj556244

  • Anonymous
    June 10, 2013
    @Fabien & @rafe - To access functions defined in the store with Code First you would need to drop down to a raw SQL query - msdn.microsoft.com/.../jj592907. We do plan to add better support in the future.

  • Anonymous
    June 10, 2013
    @Ahsan Kabir - If it's a Web Application then right-click on the References folder and choose 'Manage NuGet Packages...'. For Web Sites, right click on the project and select the same option. Make sure you change the dropdown at the top of the dialog from 'Stable Only'  to 'Include Prerelease'.

  • Anonymous
    June 10, 2013
    @Rowan Miller thanks, I found it :)

  • Anonymous
    June 10, 2013
    So, is there any way to test that SqlAzureExecutionStrategy is configured and working?

  • Anonymous
    June 11, 2013
    @Alex Dresko - One way to test it out would be to use the new DbCommand interception feature to artificially throw one of the retryable exceptions the first time you run a query. Arthur from our team wrote a great blog post that shows how to create an interceptor - blog.oneunicorn.com/.../ef6-sql-logging-part-3-interception-building-blocks. You could then see the query retry after the exception was thrown.

  • Anonymous
    June 19, 2013
    I'm quite disappointed there still no support for federations...

  • Anonymous
    June 20, 2013
    How about secondary Distributed Cache?  NHibernate has excellent pluggable secondary cache support.  It truly does wonders for scalability.  With AppFabric's distributed cache service finally being released, MS has an answer to memcache.  There's even a few external implementations.   Any hope of bringing distributed caching into EF any time soon?

  • Anonymous
    June 21, 2013
    @Brad Gronek - When we look at second level cache support we'll be building in hooks to plug in different solutions (that's how we try to design all new features nowadays). This would allow you to plug in a distributed cache. We don't have any timelines for second level cache support though - just that it won't be in EF6.

  • Anonymous
    June 26, 2013
    extend custom convention to can ignore property by such a modelBuilder.Properties().where(some conditions )Configure(p=>p.Ignore()). current ignoring property by fluent api is useless in existing POCCO classes.

  • Anonymous
    June 28, 2013
    @Hossein Razzaghi: You can ignore a property from an entity type convention. It allows you create simple conditions, like this: public interface IIgnorable {    int IgnoreMe { get; set; } } public class Person : IIgnorable {    public int Id { get; set; }    public string Name { get; set; }    public int IgnoreMe { get; set; } } public class CrowdContext : DbContext {    public DbSet<Person> People { get; set; }    protected override void OnModelCreating(DbModelBuilder modelBuilder)    {        modelBuilder.Entities<IIgnorable>().Configure(conf => conf.Ignore(entity => entity.IgnoreMe));    } }

  • Anonymous
    June 28, 2013
    @Diego B Vega [MSFT] - thanks, but your soulution applicable when column name(property of class) is predefine. problem is when column name not predefined. imagine states like this, that we have attribute on properties and we want ignore all column that they don't have the attribute: public class Person {   [column()]   public int Id { get; set; }   [column()]   public string Name { get; set; }   public int IgnoreMe { get; set; } // we want ignore   public int Age { set; get; } /* we want ignore and we don't want change POCCO class and add [NotMapped] attribute to                this classes.  */ } public class CrowdContext : DbContext {   public DbSet<Person> People { get; set; }   protected override void OnModelCreating(DbModelBuilder modelBuilder)   {         // this code is not supported      modelBuilder.Properties().Where(p => p.(don't have column attribute)).Configure(p => p.Ignore());   } } I want ignore column by such a then mentioned scenario. and only possible way is use sort of fluent api and some complicated work of lambad expression that is not work at all time. but goal of fluent api is to simple use. it seems that best way to ignore properties in the same situation is custom convention that support : modelBuilder.Properties().Where(p => p.(don't have column attribute)).Configure(p => p.Ignore());

  • Anonymous
    June 28, 2013
    @Seyyed Hossein Razzaghi: I know this looks more complicated than what you are asking for but it should work:            modelBuilder                .Entities()                .Configure(conf => conf                    .ClrType                    .GetProperties()                    .Where(p => p.GetCustomAttribute<ColumnAttribute>() == null)                    .ToList()                    .ForEach(p => conf.Ignore(p))); I logged a bug for us to consider enabling the pattern you suggest on property configurations at entityframework.codeplex.com/.../1347, but I cannot promise that we will do this in either EF6 or in the future.

  • Anonymous
    June 30, 2013
    Need the entity designer to generate nodes inside .edmx file in exactly the same order they are present in the database (currently a list of entity properties is saved in reverse order in mappings section, also when you update the model from the database schema the ordering is messed up). Also before saving .edmx file EF Designer should auto format the document. This would help significantly with branching and merging of .edmx files in a source control system.

  • Anonymous
    June 30, 2013
    visualstudio.uservoice.com/.../4142937

  • Anonymous
    June 30, 2013
    @Konstantin: Thanks for the feedback. Are you seeing different behavior between the designer that we shipped in Visual Studio 2012 and the new one? If yes, the most direct way for providing this sort of feedback if to log a bug on our Codeplex site:  entityframework.codeplex.com/.../Create. There you can add a repro and screenshots. If this is an idea or suggestion for an improvement, please add it in our own UserVoice page: http://ef.mswish.net. We monitor that page (not the Visual Studio one) because there we can get a better sense of the relative popularity of ideas and improvements for EF.

  • Anonymous
    July 03, 2013
    The comment has been removed

  • Anonymous
    July 03, 2013
    @kh - You can't change the model after the context has been created. You can have dynamic code in your OnModelCreating method to alter the model as it is created and you don't need DbSets exposed for the types in your model - just call modelBuilder.Entity for the types you want included. You can also create a DbContext directly by creating a DbModelBuilder, adding entities with the Entity method, calling Build to get a DbModel, then Compile to get a DbCompiledModel which can be used to create a DbContext (no need for a derived context).

  • Anonymous
    July 15, 2013
    TVP support would be nice... data.uservoice.com/.../1015347-table-valued-parameters-support

  • Anonymous
    August 07, 2013
    Navigation properties are apparently lazy loaded now in such a way that it causes "function evaluation requires all threads to run" error. When I am running unit tests and I check for a value like "Assert.AreEqual("Jones", workOrder.Employee.LastName);" I will now get an exception.  This issue does not happen in EF 5.0.  Is there a setting somewhere I need to pass in to get this to work properly?

  • Anonymous
    August 07, 2013
    @Dan A - If you could open a new issue on our CodePlex site with details about how to reproduce the issue that would be great - entityframework.codeplex.com/.../Create

  • Anonymous
    August 28, 2013
    Is there a reason IDbSet<T> does not have access to the Async extension methods? It is annoying having to cast from IDbSet<T> => DbSet<T> just so I can use the new Async goodness.

  • Anonymous
    August 28, 2013
    @Paul - The Async extension methods are extensions to IQueryable<T> and will work with IDbSet<T> (you just need to make sure you have the System.Data.Entity namespace imported to have the extension methods available). We didn't add the async instance methods on DbSet<T> (like FindAsync) to IDbSet<T> because we made some other changes to make DbSet<T> easier to use when testing, without the need for an interface. Given this we didn't want to take a breaking change to the existing interface. Here are examples of using DbSet for testing without the interface: