Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I think i red news that you are able to create Stored Procedures through EF 6 some time before, but what i see now is some mapping and field editing options

Stored procedure creation was not supported before, but i dont understand what exactly they introduced in the end, can someone maybe tell me the functionality behind these changes?
Or can someone redirect me to a How-to create stored procedures with EF?


You do it like this...[^]

You cannot create any old stored procedure you want in EF6. You merely tell it to create the standard CRUD operations in stored procedures.
Share this answer
EDM designer doesn’t allow you to write stored procedures and bring them into the database. That means it doesn’t matter whether you opt for the code-first, model-first or database-first approach. You always have to create your stored procedures in the database and later import them into the EDM.

But You Can Do That...

protected override void OnModelCreating(DbModelBuilder modelBuilder)
        DbCommand cmd = Database.Connection.CreateCommand();
        cmd.CommandText = "create stored procedure ....";

And For Mapping You Can Use

  .MapToStoredProcedures(s => 
    s.Update(u => u.HasName("UpdateStoreProcedureName")) 
     .Delete(d => d.HasName("deleteStoreProcedureName")) 
     .Insert(i => i.HasName("insertStoreProcedureName"))); 

You Can Also Read This Link
Share this answer
Check this sample application:

Entity Framework for Beginners[^]
Share this answer
Naz_Firdouse 8-Apr-14 8:04am    
you are posting solution to the query which was asked more than an year ago...that too for all queries where EntityFramework tagged. Do you believe that the article solves all the questions?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900