dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.51k stars 3.13k forks source link

Support stored procedures without a table mapping #28703

Open roji opened 1 year ago

roji commented 1 year ago

Stored procedure mapping (#28553) currently requires that a table mapping be defined; the table mapping is necessary in order for us to properly perform topological sort (e.g. know about dependencies between tables). It makes sense for users to use views/functions for querying and only sprocs for updating, in which case a table mapping isn't strictly speaking necessary.

See conversation in https://github.com/dotnet/efcore/pull/28553#discussion_r943731844

PolkageistHS commented 1 year ago

In the meantime, can the exception message be updated to reflect that non-tables are not supported? It still says "An entity type that isn't mapped to a table must be mapped to insert, update and delete stored procedures." but the code doesn't allow any SP mapping to non-tables.

https://github.com/dotnet/efcore/blob/afe9bc16a8cb5ac5cb8bf3538399879c673a1b9c/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L249

https://github.com/dotnet/efcore/blob/afe9bc16a8cb5ac5cb8bf3538399879c673a1b9c/src/EFCore.Relational/Properties/RelationalStrings.resx#L1094-L1096