An Expert Workaround for Executing Complex Entity Framework Core Stored Procedures

, Software Pundits
This post was originally published on this site

Toptal

.NET developers often need to call a database stored procedure (SP) from their C# server layer. Microsoft’s Entity Framework (EF) Core can be used to map or import SPs as functions but, unfortunately, EF Core doesn’t natively support the retrieval of complex results from stored procedures. This is due to limitations in EF Core’s out-of-the-box solution that:

Restrict a stored procedure’s result to an Entity type. Cannot return a complex type in response to a JOIN command. Make create, update, and delete operations unavailable.

We can get around these restrictions by using C#, .NET, Microsoft SQL Server, and EF Core together. This workaround can be used with any .NET-supported database or .NET language that supports EF Core, provided the utility code is translated into that language. We’ll look at an example stored procedure to see how a few simple adjustments can overcome EF Core’s constraints.

A Hypothetical Stored

To read the full article click on the 'post' link at the top.