Announcing Entity Framework 6.3 Preview with .NET Core Support

Diego Vega

The first preview of the EF 6.3 runtime is now available in NuGet.

Note that the package is versioned as 6.3.0-preview5. We plan to continue releasing previews of EF 6.3 every month in alignment with the .NET Core 3.0 previews, until we ship the final version.

What is new in EF 6.3?

While Entity Framework Core was built from the ground up to work on .NET Core, 6.3 will be the first version of EF 6 that can run on .NET Core and work cross-platform. In fact, the main goal of this release is to facilitate migrating existing applications that use EF 6 to .NET Core 3.0.

When completed, EF 6.3 will also have support for:

  • NuGet PackageReferences (this implies working smoothly without any EF entries in application config files)
  • Migration commands running on projects using the the new .NET project system

Besides these improvements, around 10 other bug fixes and community contributions are included in this preview that apply when running on both .NET Core and .NET Framework. You can see a list of fixed issues in our issue tracker.

Known limitations

Although this preview makes it possible to start using the EF 6 runtime on .NET Core 3.0, it still has major limitations. For example:

  • Migration commands cannot be executed on projects not targeting .NET Framework.
  • There is no EF designer support for projects not targeting .NET Framework.
  • There is no support for building and running with models based on EDMX files on .NET Core. On .NET Framework, this depends on a build task that splits and embeds the contents of the EDMX file into the final executable file, and that task is not available for .NET Core.
  • Running code first projects in .NET Core is easier but still requires additional steps, like registering DbProviderFactories programmatically, and either passing the connection string explicitly, or setting up a DbConnectionFactory in a DbConfiguration.
  • Only the SQL Server provider, based on System.Data.SqlClient, works on .NET Core. Other EF6 providers with support for .NET Core haven’t been released yet.

Besides these temporary limitations, there will be some longer term limitations on .NET Core:

  • We have no plans to support the SQL Server Compact provider on .NET Core. There is no ADO.NET provider for SQL Server Compact on .NET Core.
  • SQL Server spatial types and HierarchyID aren’t available on .NET Core.

Getting started using EF 6.3 on .NET Core 3.0

You will need to download and install the .NET Core 3.0 preview 5 SDK. Once you have done that, you can use Visual Studio to create a Console .NET Core 3.0 application and install the EF 6.3 preview package from NuGet:

PM> Install-Package EntityFramework -pre

Next, edit the Program.cs file in the application to look like this:

using System;
using System.Linq;
using System.Data.Entity;
using System.Data.Common;
using System.Data.SqlClient;

namespace TryEF6OnCore
{
    class Program
    {
        static void Main(string[] args)
        {
            var cs = @"server=(localdb)\mssqllocaldb; database=MyContext; Integrated Security=true";

            // workaround:
            DbProviderFactories.RegisterFactory("System.Data.SqlClient", SqlClientFactory.Instance);

            using (var db = new MyContext(cs))
            {

                db.Database.CreateIfNotExists();
                db.People.Add(new Person { Name = "Diego" });
                db.SaveChanges();
            }

            using (var db = new MyContext(cs))
            {
                Console.WriteLine($"{db.People.First()?.Name} wrote this sample");
            }
        }
    }

    public class MyContext : DbContext
    {
        public MyContext(string nameOrConnectionString) : base(nameOrConnectionString)
        {
        }

        public DbSet People<Person> { get; set; }
    }

    public class Person
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }

}

Closing

We would like to encourage you to download the preview package and try the code first experience on .NET Core and the complete set of scenarios on .NET Framework. Please, report any issues you find to our issue tracker.

51 comments

Discussion is closed. Login to edit/delete existing comments.

  • Damien Dennehy 0

    There is no support for building and running with models based on EDMX files on .NET Core.
    Is there a plan to support this in 6.3 final? Our main data access layer uses a Database first EDMX. I accept that it might not be possible at all but if we have a definitive statement on this at least we can move forward with a migration plan.

    • Diego VegaMicrosoft employee 0

      We plan to address this before RTM. It is one of the temporary limitations we expect to remove.

      Right now it should be possible to achieve by programmatically splitting the EDMX model into CSDL, MSL and SSDL, and then feeding those into a MetadataWorkspace. It is just so far from the automatic experience available in .NET Framework that I decided not to even mention it.

      • Damien Dennehy 0

        That is really good news to hear, appreciate the feedback!

  • Jonathan Allen 0

    So what are we supposed to do about spatial types? Use .NET Framework forever?

    • Ri Scott 0

      Yeah, could someone speak to the spatial data type roadmap? I have an application that I would really like to port to .NET Core, but spatial data types are a requirement.

      • Diego VegaMicrosoft employee 0

        We are still discussing this with the SQL Server team that owns spatial types, to help them prioritize .NET Core support. What can help the most at this stage is concrete examples of applications that you plan to build or port if this functionality becomes available on .NET Core.

        I will soon be able to share a GitHub issue in which you can provide this additional information.

  • Robert McLaws 0

    Regarding the EDMX issue, I built a T4 generator to solve this problem for SDK projects targeting the .NET Framework about a year ago. I’ve open-sourced it at https://github.com/CloudNimble/EF6.3MetadataGenerator. Hopefully it helps fill in the gap.
    I’ve opened an issue on GitHub (https://github.com/aspnet/EntityFramework6/issues/828) to discuss if this would be useful in the final product, or what other alternatives are possible.
    Please let me know if there is any way I can help.

    • Diego VegaMicrosoft employee 0

      Thanks for putting this together Robert.

  • Stilgar Naib 0

    Will you also release Core versions of ASP.NET Identity?

    • Diego VegaMicrosoft employee 0

      Do you mean an EF6-based provider for ASP.NET Core Identity? I am not aware of any plans but it may be a good idea to ask in the ASP.NET Core repository on GitHub. Even if the ASP.NET team doesn’t plant to do it you may find other likeminded developers that are may want to do this or perhaps already have it.

      • Stilgar Naib 0

        No, I mean the old one without Core in the name. EF6 based provider for ASP.NET Core Identity would be even more useful but obviously requires a lot more work. Porting the old Identity once you have EF6 should be relatively straight-forward and will provide painless upgrade path for people who have built apps using it. Using the new Identity Core (in the absence of EF6 provider) would mean using both EF Core and EF6 together and having two separate User objects so we can manage relations to other objects from the user table. Of course we can use the old Identity without any port but then we have to deal with the warnings that the package is not .NET Standard complient and in addition it would be nice if the required changes are made to make it cross-platform (I think there are a couple of cryptography API calls in it that are Windows specific).

        • Diego VegaMicrosoft employee 0

          There are no plans to do that. In fact, the port of ASP.NET Identity to .NET Core is ASP.NET Core Identity. If you are hitting any specific difficulties adopting the latter, I would recommend posting feedback or questions to the ASP.NET Core repo on GitHub.

          • Tom Wilson 0

            We are using nuget package Install-Package Microsoft.AspNet.Identity.EntityFramework -Version 2.2.2 
            Will this be available to be used with EF 6.3 and .net core 3?

  • Ben Hayat 0

    Diego, I’m a bit confused.Is 6.3 for the developers who are using .Net and EF 6 to move to .Net Core or 6.3 the new version # for those who are building .Net Core apps?As of april 18th it was called “Entity Framework Core 3.0 Preview 4”. Now it suddenly became “Entity Framework 6.3 Preview”?I think this blog needs a bit more clarification.Thanks!..Ben

    • Diego VegaMicrosoft employee 0

      This post is about the next minor version of EF6, that now happens to also run on .NET Core. 

      EF Core and EF6 remain two different products, and nothing else has changed.

      • Ben Hayat 0

        >>EF Core and EF6 remain two different products, and nothing else has changed<<

        Thanks for the clarification Diego. So many new news coming out this week and want to make sure I’m clear on them.

    • Diego VegaMicrosoft employee 0

      Thank you for sharing this workaround, Bill!

  • Weijie JIN 0

    Thanks Diego for the update.
    I know it maybe duplicated, but just want to mention that please put Database first in priority because a lot of big and complex projects are using DB first approach.

    Thanks!

    • Diego VegaMicrosoft employee 0

      Thanks for the feedback. Should I assume that you mean specificically reverse engineering of a database into an edmx file, as opposed to reverse engineering into a “code first” model?

  • Philip Gruebele 0

    Lack of support for SQL Server spatial types will prevent our app (and I am sure many others) from migrating to EF 6.3/.Net Core 3.
    This seems like a grave oversight to me.

    • Diego VegaMicrosoft employee 0

      See my answer above. This is something we are discussing with the SQL Server team.

  • Werner Kellens 0

    With the limitations for EF 6.3 is it better to write a datalayer in .NET Framework? So that your .NET Core/Stardard can communicate with the datalayer. And then in the future migrate to .NET Core en .NET Core EF

    • Diego VegaMicrosoft employee 0

      I am not sure what you mean, but for what it is worth, as explained in the blog post, many of the limitations are temporary and should be addressed before RTM.

  • tom.wilson 0

    I would like to adopt this by sharing my “Model” project which contain by DBContext and is currently being used by .net 4.6 with a .net core v3 app.  Would I need to uprgade my “Model” project to be on .net standard, so that both my new .net core v3 projects and my .net 4 projects can co-exist?

Feedback usabilla icon