How to run stored procedures in Entity Framework Core?

eadam picture eadam · Feb 19, 2015 · Viewed 135k times · Source

I am using EF Core 1.0 in an ASP.NET Core App. Can you please point me to the proper way of executing stored procedures? The old method with ObjectParameters and ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction is not working.

Answer

Arvin picture Arvin · Dec 16, 2015

Support for stored procedures in EF Core 1.0 is resolved now, this also supports the mapping of multiple result-sets.

Check here for the fix details

And you can call it like this in c#

var userType = dbContext.Set().FromSql("dbo.SomeSproc @Id = {0}, @Name = {1}", 45, "Ada");