How to use stored procedures in Entity Framework 6-database first?

c# entity-framework-6 stored-procedures

Question

I have an already existing database and i generated my ".edmx" file from the database. After that i added the stored procedure via update model from database menu and in the model browser i can see my procedure name and complex type but i can't see the complex type in the "IntelliSense".

dbContext.Database.SqlQuery<mycomplextype>

IntelliSense doesn't show the complex type when i write thecode to call the stored procedure. I didn't see anything related to the stored procedure in the context class either.

What is the proper way to add and use stored procedure in entity framework database first? Can anyone point out what i am missing?

Thank you.

Edit:

dbcontext.storedprocedurename

I can't see my stored procedures name in this way but the edmx shows the procedure in the function imports section in model browser.

1
1
6/9/2015 6:56:37 AM

Popular Answer

I got 6.1.3 EntityFramework version and I am using Database First approach.

To use my stored procedure i added it to the Model with the helper it is reference as a method and call it like so in query

Dbcontext.StoredProcedureName(prop1,prop2,..); Dbcontext.SaveChangesAsync();
1
6/8/2015 1:48:11 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow