Home > Articles > Details

How to call a store procedure in Entity Framework Core 2.2.1 without a Model Generated


Problem: When working in ASP.Net Core 2.2.1, you might find yourself in need to just insert the data without going throught the trouble of updating the Models in the Data Context.

This rather a painful procedure if you don't know what you are doing, to help you resolve the problem, below is the solution. I must say that some solutions might not work with your specific problem, in this case keep on experimenting and find what works in your scenerial.

Login to See the Rest of the Answer

Answer:
List SqlParameter sqlParameters = new List SqlParameter();
sqlParameters.add("AddYourParameterAsShownInDB",ValueHere);
sqlParameters.add("AddYourParameterAsShownInDB",ValueHere);

_context.Database.ExecuteSqlCommand("NameOfYourStoreProc ParameterAsShownInDB, AnotherParameterAsShownInDB", ValueOfParameterOne, ValueOfParameterTwo);


If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.

John said:

Thank you, this really helped me resolve the problem.

Posted On: September 17, 2019 7:06:18 AM

© 2022 - ErnesTech - Privacy