News

Entity Framework Core 5 RC1 Is Feature Complete, Ready for Production

The first release candidate for Entity Framework 5 -- Microsoft's object-database mapper for .NET -- has shipped with a go live license, ready for production.

Now the dev team is focused on fixing any remaining critical bugs before the official November debut, with one more RC on tap before then, as EF Core's development mirrors .NET 5 itself, also out in RC1.

"This is a great opportunity to start using EF Core 5.0 early while there is still time to fix remaining issues," said Jeremy Likness, senior program manager, .NET Data and .NET, in a recent blog post. "We're looking for reports of any remaining critical bugs that should be fixed before the final release.

"This release includes new features like many-to-many, property bags, event counters, required 1:1 dependents and the ability to intercept SaveChanges and listen to save events. It also includes improvements to model-building, migrations, and more."

The EF Core CLI
[Click on image for larger view.] The EF Core CLI (source: Microsoft).

One area that received a lot of attention in the new RC1 is migrations. As Microsoft explains, "In real-world projects, data models change as features get implemented: new entities or properties are added and removed, and database schemas needs to be changed accordingly to be kept in sync with the application. The migrations feature in EF Core provides a way to incrementally update the database schema to keep it in sync with the application's data model while preserving existing data in the database."

Options for migration generation have been improved in the new update, providing developers with greater control depending upon the purpose. Developers can now:

  • Know if the migration is being generated for a script or for immediate execution
  • Know if an idempotent script is being generated
  • Know if the script should exclude transaction statements

Regarding the latter item related to transactions, Likness said, "SQL scripts generated from migrations now contain statements to begin and commit transactions as appropriate for the migration."

Developers can also now exclude tables from migrations: "It is sometimes useful to have a single entity type mapped in multiple DbContexts. This is especially true when using bounded contexts, for which it is common to have a different DbContext type for each bounded context." More on that feature can be found here.

A community contributor, Turner Bass, provided other new functionality for migrations: the ability for developers to see pending migrations via a new command available to list migrations not yet applied to a database.

Yet another new migrations tweak improves migrations column ordering. For new tables created by a developer, "The columns for unmapped base classes are now ordered after other columns for mapped entity types."

In the previous Preview 8, Migration functionality for SQLite tables also received some attention: "Compared to other database, SQLite is relatively limited in its schema manipulation capabilities. For example, dropping a column from an existing table requires that the entire table be dropped and re-created. EF Core 5.0 Migrations now supports automatic rebuilding the table for schema changes that require it."

Earlier this year, Visual Studio Magazine contributor Eric Vogel provided his own guidance on Entity Framework Core Migrations.

Here's a high-level summary of how Likness described some of the other new features in RC1:

  • Many-to-many: "EF Core 5.0 supports many-to-many relationships without explicitly mapping the join table."
  • Map entity types to queries: This functionality, which was actually previously available, has been improved and sports new syntax. "Entity types are commonly mapped to tables or views such that EF Core will pull back the contents of the table or view when querying for that type. EF Core 5.0 allows an entity type to mapped to a 'defining query'."
  • Event counters: ".NET event counters are a way to efficiently expose performance metrics from an application. EF Core 5.0 includes event counters under the Microsoft.EntityFrameworkCore category."
  • Property bags: "EF Core 5.0 allows the same CLR type to be mapped to multiple different entity types. Such types are known as shared-type entity types. This feature combined with indexer properties (included in preview 1) allows property bags to be used as entity type."
  • SaveChanges interception and events: "EF Core 5.0 introduces both .NET events and an EF Core interceptor triggered when SaveChanges is called."

These enhancements and many more are explained in more detail in the announcement post and the What's New in EF Core 5.0 site, which also list what's new in the previous string of preview updates.

Full EF Core documentation can be found here, while issues and requests and be filed on the GitHub site here.

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus

Featured

  • C# Slides in Usage Ranking of Programming Languages

    "The fact that C# lost three places in the ranking of language communities during the last three years is mostly explained by its slower growth compared to C/C++ and PHP."

  • Telerik UI for Blazor Updated

    Progress announced an update to its Telerik UI for Blazor components, targeting Microsoft's open source Blazor framework that lets C# coders create web apps without having to rely upon JavaScript.

  • Infragistics Unveils UI Components for Blazor

    Infragistics, specializing in third-party UI/UX controls and tools, unveiled a new offering targeting Blazor, Microsoft's red-hot open source framework that allows for C#-based web development instead of traditional mainstay JavaScript.

  • AWS Open Sources Tool for Porting .NET Framework Apps to .NET Core

    Leading cloud computing platform Amazon Web Services open sourced the it announced in July for helping users port old .NET Framework applications to the new .NET Core framework.

  • Uno Platform Ports Windows Calculator to Linux

    Uno Platform has ported the famed Windows Calculator, open sourced last year, to Linux as part of a continuing "proof point" effort to demonstrate the reach of what it describes as the sole UI offering available to target Windows, WebAssembly, iOS, macOS, Android and Linux with single-codebase applications coded in C# and XAML.

Upcoming Events