I have been using the following code to execute a stored procedure in my C# controllers. db is my EF database context.

var sql = @"dbo.sp_add_test @CreatedBy, @CreatedDate, @TestId, @TestStatusId"; List<SqlParameter> parameterList = new List<SqlParameter>(); parameterList.Add(new SqlParameter("@CreatedBy", Int32.Parse(User.Identity.GetUserId()) )); parameterList.Add(new SqlParameter("@CreatedDate", DateTime.UtcNow)); parameterList.Add(new SqlParameter("@TestId", testId)); parameterList.Add(new SqlParameter("@TestStatusId", 3)); SqlParameter[] parameters = parameterList.ToArray(); var test = await db.Database.SqlQuery<Test>(sql, parameters).FirstOrDefaultAsync();

I've had suggestions "why don't you map your SP in the EF context?" However when I did research on this I found it very unclear as to how to do this. First of all I saw there's a nuget package out there:

http://www.nuget.org/packages/EntityFramework.CodeFirstStoreFunctions/

But I am not clear. Is this the only way to do it or has something changed. I see posts on the internet and SO but it appears that things are changing very recently so I think these may now be out of date.

Can someone tell me how it's now done for EF 6.1.1. Please note I am looking for the official way to do this using only Microsoft tools. Also note I am using Code First so I cannot use the edmx mapper etc.