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 at Converge 360.

comments powered by Disqus

Featured

  • Build Your First AI Applications with Local AI

    "AI right now feels like a vast space which can be hard to jump into," says Craig Loewen, a senior product manager at Microsoft who is helping devs unsure about making that first daunting leap.

  • On Blazor Component Reusability - From Day 0

    "We want to try to design from Day One, even Day Zero, with reusability in mind," says Blazor expert Allen Conway in imparting his expertise to an audience of hundreds in an online tech event on Tuesday.

  • Decision Tree Regression from Scratch Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of decision tree regression using the C# language. Unlike most implementations, this one does not use recursion or pointers, which makes the code easy to understand and modify.

  • Visual Studio's AI Future: Copilot .NET Upgrades and More

    At this week's Microsoft Ignite conference, the Visual Studio team showed off a future AI-powered IDE that will leverage GitHub Copilot for legacy app .NET upgrades, along with several more cutting-edge features.

  • PowerShell Gets AI-ified in 'AI Shell' Preview

    Eschewing the term "Copilot," Microsoft introduced a new AI-powered tool for PowerShell called "AI Shell," available in preview.

Subscribe on YouTube