-
-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support stored procedures #18
Comments
As EF Core does not support stored procedures (to a large extent) - could you give an exmaple of what type of support you are looking for? |
From @OmiCron07 on April 2, 2018 15:25 I don't know exactly what you can currently do, but in the meantime, I think I will use this NuGet : https://github.com/verdie-g/StoredProcedureEFCore Can you list the stored procedures in the database and create some classes or constants with their parameters, because, I don't want to use magic string. That would be nice to import the stored procedure with its list of parameters and using these with the other library. |
Moving to backlog - PRs accepted! |
Hi @ErikEJ, I'm using Ef Power Tools to reverse engineer my sql server database in a c# Core 2.2 project. It's been great so far, but now I have a query that is just too complicated to try to write in linq. I can put it in a view or a stored procedure but I can't seem to find anything on how to include views or procs in the reverse engineer process. This thread seems the closest dead end I've found. Can you point me in a good direction? Thanks. |
Just extend your DbContext manually, and/or use FromSql. EF Core 3.0 can map views for you. |
Thanks. I was able to use FromSql to get something functional for now. I'll clean it up down the road after we update to Core 3.x. |
In the meanwhile, have a look here: https://github.com/DarioN1/SPToCore |
I have now started work on this: |
@Tagwerk-Berlin and others - this is now in the latest daily build. |
This is now completed for SQL Server. |
Hi Eric, this looks like it could be a great update for us. Since my last question on this thread we've updated our project to Core 3.1 and I'm currently calling stored procedures like my code example below. I've reverse engineered my entities with the new Generate stored procedures mappings box checked and I see the new procedure models all with "Results" tacked on to the name. Most of my procedures don't actually return data, they just handle bulk operations EF struggles with, so their new models are empty. Would this update allow me to call the procedures differently? And if so would you mind a quick example of how you'd handle something like the code below? My procs are not on dbo schema if that causes issues. Thanks. SqlParameter[] spa = new[] { |
@intomneato have you tried it? And have you read the wiki docs? |
@intomneato Actually unsure how I deal with procedures with no result... Let me know your findings. |
Yes, I've been messing with it this morning trying to see how I can use the new models but so far I have not figured out how to call the procedures. Should I be able to do something like... |
That blog was helpful, though following the first code example in my own project implementation my ContextProcedures does not appear to have any of my procedures as objects within it. Is that due to my procs being in a different schema than dbo maybe? |
@intomneato doubt it, maybe because they are not returning results. |
I'm running a little short on time today to spin up a project, but I just tried creating a testing proc with a return value in my real project, after a fresh reverse engineer it did show up in my ContextProcedures.cs file and was an available object to use in code. So I'd say that pretty well confirms that you are right, lack of return value is the problem. I guess I could add a return value to my other procs as a work around, even if it's just a bool to say it finished or if it hit the catch in the proc. |
Please create an issue for this, and I will investigate... |
No problem. Issue #449 created. Thanks for your help, EFCorePowerTools really is very helpful and easy to use! |
From @OmiCron07 on April 2, 2018 15:8
Copied from original issue: ErikEJ/SqlCeToolbox#680
The text was updated successfully, but these errors were encountered: