locked
Adding stored procedures to EF when doing code first (For already Existing but forgot to add Store porcedures warlier) RRS feed

  • Question

  • User-1102892401 posted
    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    
            {
    
                modelBuilder.Entity<yourEntityName>().MapToStoredProcedures();
    
            }

    This above code can be used while creating code first approach EF.But what is the process to access Stored procedure for already Existing Entity model?Please Help.Thanks in advance

    Thursday, November 2, 2017 9:51 AM

All replies

  • User1120430333 posted

    You can call a stored procedure in the DbContext class as follows.

    this.Database.SqlQuery<YourEntityType>("storedProcedureName",params);
    Thursday, November 2, 2017 8:55 PM