- [Narrator] Entity Framework Core 6
is an application framework
that released alongside .NET6.
It is a lightweight, extensible,
open source and crafts platform version
of the classic entity framework data access technology.
Entity framework, often shortened to EF,
is an ORM and object relational mapper tool.
We use it to map .NET objects to relational databases.
One of the keywords here is lightweight.
Historically, Entity Framework was effective
but often resulted in code bold.
That's all changed with EF Core
which functions more like a micro ORM than is predecessor.
Here are some of the new features;
SQL server temporal tables
automatically keep track of all data ever stored in a table.
Even after that data has been updated or deleted.
This is useful for auditing, rebuilding the data
in case of accidental
or destructive changes
and reporting on historical trends.
EF Core now supports the creation of temporal tables
using migrations.
You can transform existing tables into temporal tables.
Again, using migrations, use it
to query historical data
and restore data from some point in the past.
- EF Core migrations
are used to generate database schemes updates based
on changes to the EF model.
EF core now includes a new way
to apply those schema updates.
They are called migration bundles.
A migration bundle is a small executable containing
migrations and the code needed
to apply those migrations to the database.
Run the EFC,
it updates the database with the new schema.
EF core application startup times have never been snappy.
That changes with the new compiled models feature.
If startup time for your application is important
and your EF Core model contains hundreds
or thousands of entities,
properties and relationships,
this will help.
Benchmarks show an eight to
10 times improvement from moderately large projects.
Note, there is a trade off.
When you change your model or your configuration,
you'll have to recompile the models,
and then manually sync with your application.
EF Core 6 performance is now 78% faster
on the industry standard tech empower fortunes benchmark
compared version 5.
Many of these speed improvements
are due to the performance work done by the .NET run team.
But the EF team has done their work too.
It's possible to map models to Cosmos DB data.
Here are some of the improvements;
Sometimes it's necessary to execute a raw SQL query
instead of using LINQ.
This is now supported with the Cosmos provider
through the use of the 'From SQL Raw' method.
Simple LINQ queries using distinct are now translated
to the SQL distinct statement.
The Cosmos provider now translates
more based class libraries BCL methods
to cosmos built in functions.
And finally,
the cosmos provider now logs more diagnostic information,
including advanced for inserting,
querying, updating and deleting data
from the database.
Scaffolding a database produce an entity framework model
from an existing database.
The resulting entities are created
and mapped to the tables in the specified database.
EF Core 6 detects simple joint tables
and automatically generates a many to many mapping for them.
EF Core 6 now scaffolds on EF model
and entity types that use C# nullable reference types.
This is another simple yet needed improvement.
Comments on SQL tables and columns are now scaffolded
into the entity types created when reverse engineering
and EF Core model from an existing SQL server database.
EF Core 6 contains several improvements
in the translation and execution
of LINQ queries.
Using link GroupBy now supports
selecting the top end results from a group.
It also supports calling first
or default after the GroupBy operator.
The list of improvements is long.
I encourage you to read
the entity framework what's new documentation
to discover more.
To summarize,
there are many performance enhancements
some powered by the .NET runtime improvements,
some powered by the new compiled models,
work continues to make the .Net Code model,
use the newest .NET ideas
while faithfully mapping the models
to a wide group of database providers.