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

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube