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.
.Net core 3 with Entity Framework 6.3 or EF Core 3.0? for SQL Server
Are you planning to introduce designer for DB models in a nearest future?
Code First is not a solution for me, because my apps using working db and designer is qute good option to see what tables we have and easily update it or find things we have to change, use cmd commands or something is not really comfortable.
Why is EF6.3 targeting .NET standard 2.1, which does not work with .NET framework? This means forces an “all-or-nothing” upgrade. Why not instead target .NET standard 2.0 and maxiumize prtability and a gradual migration path? The alternitive is to upgrade to EF Core, which runs on .NET Framework, which allows a gradual upgrade.
(answered the wrong question, deleted)
BTW, André’s answer is correct.
EF6.3 also supports classic .net 4.x
Dose EF 6.3 with .Net core 3 support transcationscope with msdtc?
Ivan,
No, this is not a limitation of EF per se, but there is currently no distributed transaction support in the .NET Core version of System.Transactions, so if your application code does anything that requires 2-phase commit support, you should get an exception. This is something we may consider improving in the future, at least on Windows. There is an issue tracking at https://github.com/dotnet/corefx/issues/13532.
Thanks for your reply.
Actually, some existing applications do need a distributed transaction. So hope it will support in coming release.
i love EF core because it is better to support DDD development.
p.s. About the first sentence, May I know what “se” stand for ?
With “per se” I just meant the limitation is not intrinsic to EF. By the way, feel free to vote in the GitHub issue and comment on how your application still needs distributed transactions, whether a solution for Windows only would suffice, etc.