code first stored procedure - create in code? RRS feed

  • Question

  • I am trying to create a stored procedure in code first.  I have already seen the tutorial

    at http://www.codeproject.com/Articles/179481/Code-First-Stored-Procedures , but it does

    not explain how to create the body in code first if I understand correctly, it just assumes

    you already have the body of the procedure defined in the database.  I want to know how

    to make the entire procedure in code, including the body - i.e. acode first code first stored procedure.  

    • Edited by jamesiw Thursday, December 13, 2012 7:27 PM
    Thursday, December 13, 2012 7:26 PM


  • You can execute any SQL you need to create stored procedures in a Database Initializer. These have changed quite a bit over the different versions of EF from 4.1 to 5.0 but there should be plenty of examples out there of how to do it for whichever version you are using. There is a good video tutorial on it too.

    • Proposed as answer by Alexander Sun Monday, December 17, 2012 2:09 AM
    • Marked as answer by Alexander Sun Wednesday, December 26, 2012 2:35 AM
    Friday, December 14, 2012 3:51 AM