efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Plan for Entity Framework Core 8 (EF8)

Open ajcvickers opened this issue 2 years ago • 46 comments

Today we are excited to share with you the plan for Entity Framework Core 8. This issue contains a quick summary of the plan and acts as a place for you to leave feedback.

This plan brings together input from many stakeholders and outlines where and how we intend to invest in Entity Framework Core 8 (EF Core 8; EF8)

IMPORTANT This plan is not a commitment; it will evolve as we continue to learn throughout the release. Some things not currently planned for EF8 may get pulled in. Some things currently planned for EF8 may get punted out.

General information

EF Core 8 is the next release after EF Core 7 and is scheduled to ship in November 2023, at the same time as .NET 8. EF8 currently targets .NET 6. This will likely be updated to .NET 8 as we near the release date. EF8 will align with .NET 8 as a long-term support (LTS) release. See the .NET support policy for more information.

Themes

Large investments for EF8 and data access in .NET 8 fall under the following themes:

Highly requested features

  • JSON columns Build on EF7 JSON support to further power the document/relational hybrid pattern.
  • Value objects Applications can use DDD-style value objects in EF models.
  • SQL queries for unmapped types Applications can execute more types of SQL query without dropping down to ADO.NET or using third-party libraries.

Cloud native and devices

Performance

  • Woodstar Fast, fully managed access to SQL Server and Azure SQL for .NET applications.

Visual Tooling

Developer experience

  • Make EF Core better Improve the developer experience be making many small improvements to EF Core

Find out more and give feedback

This post is a brief summary of the full EF8 plan. Please see the full plan for more information.

Your feedback on planning is important. The best way to indicate the importance of an issue is to vote (👍) for that issue on GitHub. This data will then feed into the planning process for the next release.

In addition, please comment on this issue if you believe we are missing something that is critical for EF8, or are focusing on the wrong areas.

ajcvickers avatar Dec 14 '22 10:12 ajcvickers

When will you open source Woodstar? Or at least share the code.

ErikEJ avatar Dec 14 '22 16:12 ErikEJ

@ErikEJ As soon as possible. We're not holding it back for any particular reason, and I imagine @roji will share something pretty soon after he starts working on it.

ajcvickers avatar Dec 14 '22 16:12 ajcvickers

Great. For some reason I was under the impression that @smitpatel had done a lot already..

ErikEJ avatar Dec 14 '22 16:12 ErikEJ

@ErikEJ yeah, there's already some considerable done, but not yet done... Once we have something that works and is in a state to make public, we'll definitely do that.

roji avatar Dec 14 '22 16:12 roji

To increase usefulness of DDD aggregate mapping via owned (collection) types, the owned inheritance issue would be really important: https://github.com/dotnet/efcore/issues/9630 😀

But yeah, maybe next time 😅🤞

But beside from that: Great plan as always 👍🚀

davidroth avatar Dec 14 '22 21:12 davidroth

What about recursive queries? In almost every project (if not every) I had to write some recursive CTEs, and it would be really nice if we can move this SQL to code. In SQL server, postgre and oracle, the SQL is almost identical, and I do not expect that every db provider will support them, but I believe this is somewhat missing piece...

Merry Christmas to all

shadzhipopov avatar Dec 22 '22 21:12 shadzhipopov

@shadzhipopov Make sure to vote (👍) for #2865.

ajcvickers avatar Dec 22 '22 21:12 ajcvickers

I would like to see support for Table Value Parameters (TVP). This can increase performance and simplify business logic significantly when you have to deal with larger client side collections, yet EF has very limited support. The work around using bulk copy inserts into a temp table are sub-optimal.

janstrube avatar Dec 30 '22 13:12 janstrube

Any chance to support global query filters with compiled models in the 8 timeframe?

ilmax avatar Dec 30 '22 16:12 ilmax

Please consider read-only entities (https://github.com/dotnet/efcore/issues/7586).

Misiu avatar Jan 03 '23 10:01 Misiu

@janstrube Please vote (👍) for #19016 and/or #13239. It's unlikely these will make it into 8.

@ilmax Please vote for #24897. This might make 8 based on some of the AOT work that is going on--see #29924.

@Misiu Please vote for #7586. It's unlikely this will make it into 8.

ajcvickers avatar Jan 03 '23 12:01 ajcvickers

I would love to see support for managed identities in the CosmosDB provider. For security reasons managed identities are used extensively nowadays, but some apps end up being non compliant to security best practices because they are not supported by CosmosDB EF.

It would be great to see this prioritized!

codyburkard avatar Jan 03 '23 22:01 codyburkard

@codyburkard Is this different to #26491?

ajcvickers avatar Jan 04 '23 14:01 ajcvickers

Could you consider extending support for more advance CosmosDB SQL API queries ?

YohanSciubukgian avatar Jan 05 '23 23:01 YohanSciubukgian

@YohanSciubukgian You'll need to be more specific. I suggest you look through issues labeled with "area-cosmos" and "area-query" and vote (👍) for those that you need, or file new, specific, issues for query constructs that you need and are not covered by existing issues.

ajcvickers avatar Jan 06 '23 10:01 ajcvickers

Since improved JSON/hybrid-relational support is one of the important goals of EF Core 8, I'm just including a cross-reference to #25272, since it means it is not currently feasible to map multiple CLR types to a single database column efficiently. For us, this has limited the utility of the JSON support.

Worth voting for if it affects others...

zejji avatar Jan 11 '23 15:01 zejji

It would make shared/library code more foolproof to use if the context could be configured from the app service provider similar to how IConfigureOptions works. Currently I have to provide multiple extension methods that should be called on the service collection (to add core services), AddDbContext (to add interceptors), OnModelCreating (to add model classes that would show up in migrations) etc.

bachratyg avatar Jan 11 '23 19:01 bachratyg

@bachratyg Can you file an issue for this and include considerably more detail. Ideally, include what the configuration from the service provider would look like, and how the model configuration relates to the DbContext type being configured and the DbSets it exposes.

ajcvickers avatar Jan 12 '23 18:01 ajcvickers

Full proposal here: #30061

bachratyg avatar Jan 13 '23 21:01 bachratyg

@YohanSciubukgian You'll need to be more specific. I suggest you look through issues labeled with "area-cosmos" and "area-query" and vote (👍) for those that you need, or file new, specific, issues for query constructs that you need and are not covered by existing issues.

More or less all the issues punted-for-7 & area cosmos. I have already thumbs up all issues I was interested in. https://github.com/dotnet/efcore/issues?q=is%3Aopen+is%3Aissue+label%3Apunted-for-7.0+label%3Aarea-cosmos

YohanSciubukgian avatar Feb 04 '23 08:02 YohanSciubukgian

I'm super excited about the plans you guys have here. A lot of this stuff has been on my wishlist for literally a decade.

WoodStar- would love to hear more about this and offer feedback. ADO.NET is an ancient, clunky beast and I am ecstatic it's finally getting re-written. I think you should consider offering Dapper's functionality out-of-the-box. In addition, would love to see SqlBulkCopy get some love. In an ideal world it would be able to work with DataFrame- but that would require DataFrame actually getting finished. Any chance your team can adopt it?

T4 Tooling- this is super-exciting to hear that you guys are going to improve the T4 tooling. Can you share more details around this? Will it be your team doing this or another team? Some features I'd like to see:

  1. In-box syntax highlighting support
  2. Runtime T4 templates have generated .cs files which contain comments indicating the filepath of the T4 file they came from- this file path is absolute, which causes a lot of merge conflicts when different team members have repos checked out in different folders. The filepath should either be eliminated or made relative to the sln file
  3. Razor syntax being supported in T4 would be amazing.

Database-first- I think it's fantastic you're going to ship this out-of-the-box. I've always advocated that for large enterprises, code-first is often a non-starter.

MgSam avatar Feb 23 '23 15:02 MgSam

@MgSam

WoodStar- would love to hear more about this and offer feedback. ADO.NET is an ancient, clunky beast and I am ecstatic it's finally getting re-written.

WoodStar would be about providing a fast, modern driver for SQL Server and SQL Azure, not about rewriting ADO.NET.

roji avatar Feb 23 '23 16:02 roji

@MgSam I have published a very popular extension for reverse engineering - EF Core Power Tools - since 2017...

ErikEJ avatar Feb 23 '23 16:02 ErikEJ

@MgSam

WoodStar- would love to hear more about this and offer feedback. ADO.NET is an ancient, clunky beast and I am ecstatic it's finally getting re-written.

WoodStar would be about providing a fast, modern driver for SQL Server and SQL Azure, not about rewriting ADO.NET.

Isn't that just semantics though? If EF starts using WoodStar and we can finally stop using some of these core types in ADO.NET that haven't been touched in 15 years.

@MgSam I have published a very popular extension for reverse engineering - EF Core Power Tools - since 2017...

Yes, I think it's great! But I think out-of-the-box is critical for widespread adoption of any feature. I think most devs don't install any extensions, or worse have corporate policies actively banning them.

MgSam avatar Feb 23 '23 16:02 MgSam

@MgSam I hope woodstar will just eventually be a better ADO.NET driver for Azure SQL / SQL Server...

ErikEJ avatar Feb 23 '23 16:02 ErikEJ

WoodStar would be about providing a fast, modern driver for SQL Server and SQL Azure, not about rewriting ADO.NET.

Isn't that just semantics though?

It's definitely not semantics - replacing ADO.NET means designing a new database abstraction API for .NET, which would need to make sense for all databases; the effort for Woodstar really is to provide a faster/more modern SQL Server driver. It's true that we're experimenting with non-ADO.NET API surfaces, but ultimately the driver will definitely be accessible via ADO.NET, otherwise it would be incompatible with all existing upper layers (EF, Dapper...).

If EF starts using WoodStar and we can finally stop using some of these core types in ADO.NET that haven't been touched in 15 years.

I'm not following; you can already use EF today with SqlClient and not have any contact with ADO.NET. If EF supports Woodstar in the future, it would look more or less identical to what EF looks like for current users of SQL Server. The advantage would be in performance, bug fixing and specific features, not in a new API surface.

roji avatar Feb 23 '23 18:02 roji

I'm not following; you can already use EF today with SqlClient and not have any contact with ADO.NET. If EF supports Woodstar in the future, it would look more or less identical to what EF looks like for current users of SQL Server. The advantage would be in performance, bug fixing and specific features, not in a new API surface.

Everything in EF ultimately uses SqlConnection/DbConnection when it comes down to it, no? Which is part of ADO.NET and is limited by cruft and design decisions made 15 years ago. My hope was that this project would be an investment for more modern types at the base of the db stack. SqlBulkCopy being another huge one. If that's not the case, that's a shame but I'd still be interested in learning more.

I've not yet experimented with the more recent work you guys did around bulk operation support but traditionally for the whole lifetime of Entity Framework / EF Core, if you needed to insert large amounts of data you had to use SqlBulkCopy or else suffer massive performance penalties. So EF + SqlBulkCopy has always been the reality of working with data for me in .NET. That said, SqlBulkCopy has always been a very broad hammer, it works with DataTables, has no generic object support, doesn't directly support more advanced insertion strategies like Merge. So I've always ended up wrapping SqlBulkCopy to provide additional functionality.

MgSam avatar Feb 23 '23 19:02 MgSam

Everything in EF ultimately uses SqlConnection/DbConnection when it comes down to it, no? Which is part of ADO.NET and is limited by cruft and design decisions made 15 years ago. My hope was that this project would be an investment for more modern types at the base of the db stack.

Yes, everything in EF ultimately uses ADO.net under the hood, but that doesn't really matter to anyone using EF. In other words, if we had a super nice ADO.NET replacement tomorrow, EF would still look exactly the same as it's layered on top and has its own API.

So if you're using ADO.NET directly (without EF), then it's certainly understandable that you'd want something newer to replace it. But otherwise you shouldn't really care what ADO.NET looks like.

SqlBulkCopy specifically is not part of ADO.NET at all - it's a completely SqlClient-specific API, specific to SQL Server. Other database drivers have bulk import/export APIs which look completely different.

We do intend to add a bulk import to EF, whose SQL Server implementation would be layered on top of SqlBulkCopy (see #27333); that would allow you to use bulk-insert regular entities but with SqlBulkCopy performance.

[...] it works with DataTables [...]

You can use SqlBulkCopy without DataTables - IIRC it can be used with any DbDataReader, which can be an abstraction for wrapping anything (and in that sense can serve a similar function as data frames, in this very specific sense).

[...] doesn't directly support more advanced insertion strategies like Merge [...]

That's very likely to be a limitation of SQL Server itself; bulk copy features in database are usually about inserting bulk data into a table in the fastest way possible; MERGE is something very different. A typical pattern here is to efficiently bulk insert via SqlBulkCopy into a temporary table, and then MERGE that into your destination.

roji avatar Feb 23 '23 20:02 roji

Coming here to ping second-level caching as an important feature. I commented with more detail on the backlogged specific 2lc issue here: https://github.com/dotnet/efcore/issues/27735#issuecomment-1443538978

This is the one big issue keeping us (and probably many others) from considering EF as an option. After experiencing the benefits good caching when scaling up, it becomes table stakes when choosing an ORM. Output caching is what you want for public facing apps like social media, but for SaaS apps that are mostly CRUD that doesn't work -- you really need second level caching to perform well. I check back every couple of years to see if EF is considering it, then have to go back to our hand built ORM instead because caching is so important :-/

programcsharp avatar Feb 24 '23 11:02 programcsharp

@programcsharp sure thing. I'm still not convinced that caching should be an internal concern of the ORM - as opposed to a layer above it or a plugin via interception - but that conversation is ongoing in #27735. Let's continue it there.

roji avatar Feb 24 '23 12:02 roji