StoredProcedureEFCore 0.3.13

There is a newer version of this package available.
See the version list below for details.
Install-Package StoredProcedureEFCore -Version 0.3.13
dotnet add package StoredProcedureEFCore --version 0.3.13
<PackageReference Include="StoredProcedureEFCore" Version="0.3.13" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add StoredProcedureEFCore --version 0.3.13
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: StoredProcedureEFCore, 0.3.13"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. 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=0.3.13

// Install StoredProcedureEFCore as a Cake Tool
#tool nuget:?package=StoredProcedureEFCore&version=0.3.13
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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)  // Input/Ouput parameter
IStoredProcBuilder             AddParam<T>(string name, out IOutParam<T> outParam)         // Ouput parameter
IStoredProcBuilder             ReturnValue<T>(out IOutParam<T> retParam)
void                           Exec(Action<DbDataReader> action)
void                           ExecNonQuery()
void                           ExecScalar<T>(out T val)

Exec, ExecNonQuery, and ExecScalar have a corresponding async method.


List<T>                        ToList<T>()
Dictionary<TKey, TValue>       ToDictionary<TKey, TValue>(Func<TValue, TKey> keyProjection)
Dictionary<TKey, List<TValue>> ToLookup<TKey, TValue>(Func<TValue, TKey> keyProjection)
HashSet<T>                     ToSet<T>()
List<T>                        Column<T>()
List<T>                        Column<T>(string columnName)
T                              First<T>()
T                              FirstOrDefault<T>()
T                              Single<T>()
T                              SingleOrDefault<T>()

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


Install-Package StoredProcedureEFCore

Why ?

Stored procedure execution was 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 EFCore
  • Mapping is 30% faster

NuGet packages (4)

Showing the top 4 NuGet packages that depend on StoredProcedureEFCore:

Package Downloads

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 52,344 11/15/2020
1.0.4 47,524 6/16/2020
1.0.3 305 6/15/2020
1.0.2 9,108 4/10/2020
1.0.1 10,836 2/13/2020
1.0.0 2,894 1/14/2020
0.3.15 9,393 10/30/2019
0.3.14 1,046 10/22/2019
0.3.13 438 10/17/2019
0.3.12 621 8/9/2019
0.3.11 12,708 6/1/2019
0.3.10 16,015 11/15/2018
0.3.9 7,483 5/4/2018
0.3.8 1,142 4/21/2018
0.3.7 1,001 4/3/2018
0.3.6 1,020 3/16/2018
0.3.5 786 3/16/2018
0.3.4 1,044 3/2/2018
0.3.3 1,092 2/1/2018
0.3.2 898 1/19/2018
0.3.1 884 1/8/2018
0.3.0 872 1/8/2018
0.2.0 950 12/29/2017
0.1.1 915 12/28/2017
0.1.0 799 12/26/2017