News

Microsoft Takes Entity Framework 6 to .NET Core

Microsoft announced Entity Framework 6.3 Preview, which takes the traditional open source object-relational mapping (ORM) framework to the .NET Core space, joining Entity Framework Core as an option for leveraging the upcoming .NET Core 3.0.

The preview is another part of the company's wholesale shift to the open source, cross-platform approach provided by "Core" offerings, supplanting the traditional, 17-year-old Windows-based .NET Framework scheme.

While Entity Framework was originally part of that .NET Framework, as of Entity Framework 6 the runtime was separated from that platform. Now, with the EF 6.3 preview, Microsoft is taking the first steps to help Microsoft-centric data developers move their applications to the new Core order.

As Microsoft describes:

  • Entity Framework 6 (EF6) is a tried and tested object-relational mapper (O/RM) for .NET with many years of feature development and stabilization.
  • Entity Framework (EF) Core is a lightweight, extensible, open source and cross-platform version of the popular Entity Framework data access technology.

The company is working toward a unified offering that ties everything together under the .NET 5 moniker, due next year.

In the meantime, products are moving to .NET Core piecemeal.

"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," said Diego Vega, program manager, .NET Data Access, in a blog post last week. "In fact, the main goal of this release is to facilitate migrating existing applications that use EF 6 to .NET Core 3.0."

As a first effort in that direction, the preview has some "major limitations," Vega said, listing those as:

  • 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.

Regarding the EDMX-related limitation -- a concern of several developers who commented on the post -- Vega said it was a temporary limitation expected to be removed by the time the final product ships.

In response to another question, he clarified the company's positioning on the alternative offerings: "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."

In addition to the preview limitations detailed above, longer-term limitations listed by Vega include:

  • 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.

As Microsoft works out the kinks in the v6.3 preview, it aims to eventually support:

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

Vega provided getting-started advice in his post and pointed to the project's issue tracker for further information on bug fixes and more.

The preview is available via NuGet.

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

Subscribe on YouTube