First look of Entity Framework Core 3.0

Hello everyone, January is always special for me because I started writing blog posts in January 2014 and my first post just completed 5 years which is here.

Now coming back to the current post, We have already seen some early look of Asp .Net Core 3.0 here, now let us see a quick look at what is coming with Entity framework Core 3.0.

.Net team has not yet finalized all the features which would be shipped with EF Core 3.0 but we still have a high level list of features which we can expect from EF Core 3.0 releases.

Let us see some of them.

C# 8.0 Support

As you may already know that C# 8.0 Version has been announced earlier and I have written some posts on C#8.0 features which you can see here.

With EF Core 3.0, we would be able to use some awesome features of C# 8.0 like Async streams, Nullable reference types etc. So EF Core 3.0 would be the first version to include C# 8.0 features.

Cosmos DB support

There has been quite a few demand from the developers for creating EF Core providers for Cosmos DB(Azure) and .Net team has finally decided to ship this with EF Core 3.0.

So from EF Core 3.0 on wards, there would be a Cosmos DB provider which would enable us to target Azure Cosmos DB as application database. By this, we would be able to take the advantages of Cosmos DB like 99.9% availability, global distribution, low latency etc.

Few things are already announced with EF Core 2.2 which you can see here: https://blogs.msdn.microsoft.com/dotnet/2018/10/17/announcing-entity-framework-core-2-2-preview-3/

Many to many relationship without join entity

If you are familiar with creating many to many relationships then you know that we always need to create a join entity which contains the relation with both the entities which has many to many relation which becomes the mapping table between both the entities and sometimes it becomes complex to handle them.

Shared type entities

From EF Core 3.0 would also introduce shared type entities which would allow us to use the instance of the same class to represent different entity types in same model. Thus, as we would be able to represent different entity types within same model, we would be able to eliminate the use of third entity for our many to many relation model. I personally like this feature and waiting for this.

Usage as given by the .Net team:

Usage:
modelBuilder.Entity("Cat", c =>
{
c.Property<int>("Id");
c.Property<string>("Name");
});
context.Add(new Dictionary<string, object>
{
{ "Entity type name", "Cat" },
{ "Id", 123 },
{ "Name", "Tabby" }
});
view raw Share entities hosted with ❤ by GitHub

Indexed property feature

From EF Core 3.0 on wards, we would be able to use Property bag entities which would allow us to store data in the indexed properties instead of regular properties.

Something like below example as provided by .Net team:

public class SomeEntity
{
public object this[string propertyName]
{
get
{
// get value of property named propertyName
}
set
{
// set value of property named propertyName
}
}
}

LINQ being more smart

If you are from .Net background then you might have often used LINQ to write database queries. Sometimes there is need to write more complex queries with LINQ which sometimes fails as whole query is not translated from LINQ to SQL and the exception is thrown.

From EF Core 3.0 on wards, if you write some complex LINQ queries, the system would figure out which portion of the query could be translated to SQL and it would partially translated those queries and then perform the rest of the process at client side. So more server side queries with EF Core 3.0

Query types for database views

The support for query types has been already shipped with EF Core 2.1 which would help to read the data from database, without updating them. With EF Core 3.0, we would be able to automate the creation of query types for database views

No more plans for Entity framework

.Net team gave a hint by saying no more planned features for EF 6 which may mean there would not be any more versions of EF and they would not mainly focus on EF core versions.

EF 6 on EF Core 3.0

.Net team has made it easier if you want to run EF 6 on EF Core 3.0

As per the .Net team:

We understand that many existing applications use previous versions of EF, and that porting them to EF Core only to take advantage of .NET Core can sometimes require a significant effort. For that reason, we will be adapting the next version of EF 6 to run on .NET Core 3.0. We are doing this to facilitate porting existing applications with minimal changes. There are going to be some limitations (for example, it will require new providers, spatial support with SQL Server won’t be enabled), and there are no new features planned for EF 6.

Hope it helps.

3 thoughts on “First look of Entity Framework Core 3.0

Leave a comment