StoredProcedureEFCore 1.0.5

.NET Standard 2.0
dotnet add package StoredProcedureEFCore --version 1.0.5
NuGet\Install-Package StoredProcedureEFCore -Version 1.0.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="StoredProcedureEFCore" Version="1.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add StoredProcedureEFCore --version 1.0.5
#r "nuget: StoredProcedureEFCore, 1.0.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install StoredProcedureEFCore as a Cake Addin
#addin nuget:?package=StoredProcedureEFCore&version=1.0.5

// Install StoredProcedureEFCore as a Cake Tool
#tool nuget:?package=StoredProcedureEFCore&version=1.0.5

Execute stored procedures with Entity Framework Core

DbContext extension with LoadStoredProc method which creates an IStoredProcBuilder to build a stored procedure with a custom mapping strategy using the provided DbDataReader extension.

The method handles :

  • Extra column in result set
  • Extra property in model
  • Null values in result set
  • Underscores in result set column names ("column_name" is mapped to ColumnName property)
  • Int (db) to enumeration (result model) mapping


List<Model> rows = null;

   .AddParam("limit", 300L)
   .AddParam("limitOut", out IOutParam<long> limitOut)
   .Exec(r => rows = r.ToList<Model>());

long limitOutValue = limitOut.Value;

   .AddParam("boolean_to_return", true)
   .ReturnValue(out IOutParam<bool> retParam)

bool b = retParam.Value;

   .AddParam("limit", 1L)
   .ExecScalar(out long l);



IStoredProcBuilder LoadStoredProc(string name)


IStoredProcBuilder AddParam<T>(string name, T val); // Input parameter
IStoredProcBuilder AddParam<T>(string name, T val, out IOutParam<T> outParam, int size, byte precision, byte scale); // Input/Ouput parameter
IStoredProcBuilder AddParam<T>(string name, out IOutParam<T> outParam, int size, byte precision, byte scale); // Ouput parameter
IStoredProcBuilder ReturnValue<T>(out IOutParam<T> retParam, int size, byte precision, byte scale);
IStoredProcBuilder SetTimeout(int timeout);
Task               ExecAsync(Func<DbDataReader, Task> action, CancellationToken cancellationToken);
Task<int>          ExecNonQueryAsync(CancellationToken cancellationToken);
Task               ExecScalarAsync<T>(Action<T> action, CancellationToken cancellationToken);


Task<List<T>>                        ToListAsync<T>();
Task<Dictionary<TKey, TValue>>       ToDictionaryAsync<TKey, TValue>(Func<TValue, TKey> keyProjection);
Task<Dictionary<TKey, List<TValue>>> ToLookupAsync<TKey, TValue>(Func<TValue, TKey> keyProjection);
Task<HashSet<T>>                     ToSetAsync<T>();
Task<List<T>>                        ColumnAsync<T>();
Task<List<T>>                        ColumnAsync<T>(string columnName);
Task<T>                              FirstAsync<T>();
Task<T>                              FirstOrDefaultAsync<T>();
Task<T>                              SingleAsync<T>();
Task<T>                              SingleOrDefaultAsync<T>();

All these methods have a corresponding async method : ToListAsync, ToDictionaryAsync, ...


Install-Package StoredProcedureEFCore

Why ?

Stored procedure execution was previously not supported in Entity Framework Core:

It is now supported since EF Core 2.1 but this library has few advantages compared to FromSql:

  • Extra property in the model won't throw an exception. The property keeps its default value
  • The interface is easier to use. Output parameters and return values seem difficult to use with EF Core
  • Mapping is 30% faster
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on StoredProcedureEFCore:

Package Downloads

Package Description


Package Description


Package Description


Package Description


Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.5 193,938 11/15/2020
1.0.4 64,484 6/16/2020
1.0.3 433 6/15/2020
1.0.2 10,010 4/10/2020
1.0.1 12,802 2/13/2020
1.0.0 3,644 1/14/2020
0.3.15 13,936 10/30/2019
0.3.14 2,681 10/22/2019
0.3.13 573 10/17/2019
0.3.12 824 8/9/2019
0.3.11 14,748 6/1/2019
0.3.10 19,435 11/15/2018
0.3.9 8,738 5/4/2018
0.3.8 1,356 4/21/2018
0.3.7 1,217 4/3/2018
0.3.6 1,244 3/16/2018
0.3.5 1,013 3/16/2018
0.3.4 1,252 3/2/2018
0.3.3 1,351 2/1/2018
0.3.2 1,126 1/19/2018
0.3.1 1,099 1/8/2018
0.3.0 1,107 1/8/2018
0.2.0 1,199 12/29/2017
0.1.1 1,193 12/28/2017
0.1.0 1,036 12/26/2017