Comments (22)
I have now started work on this:
- Get stored procedure model ( thanks @DarioN1 )
- Write result classes ( thanks @Lupin1st )
- Write extended DbContext
- Add scaffolder tests - test based on result set with all possible parameter types
- Add hidden option to generate stored procedures (will generate all initially)
from efcorepowertools.
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 efcorepowertools.
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.
from efcorepowertools.
Moving to backlog - PRs accepted!
from efcorepowertools.
from efcorepowertools.
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.
from efcorepowertools.
Just extend your DbContext manually, and/or use FromSql. EF Core 3.0 can map views for you.
from efcorepowertools.
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.
from efcorepowertools.
https://github.com/Lupin1st/efcore_scaffold_stored_procedures
from efcorepowertools.
In the meanwhile, have a look here: https://github.com/DarioN1/SPToCore
from efcorepowertools.
@Tagwerk-Berlin and others - this is now in the latest daily build.
from efcorepowertools.
This is now completed for SQL Server.
from efcorepowertools.
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[] {
new SqlParameter("@account", a.AccountId),
new SqlParameter("@customer", a.CustomerId),
new SqlParameter("@supplier", a.SupplierId)
};
_context.Database.ExecuteSqlRaw("EXEC nsd.Account_Suspend @account, @customer, @supplier", spa);
from efcorepowertools.
@intomneato have you tried it? And have you read the wiki docs?
from efcorepowertools.
@intomneato Actually unsure how I deal with procedures with no result... Let me know your findings.
from efcorepowertools.
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...
Account_SuspendResult result = _context.Account_Suspend(a.AccountId, a.CustomerId, a.SupplierId);
instead of the code block I posted above? I have the result model, but the proc is still not a known object. I was just wondering if you had some examples or use cases. I did not see anything in the wiki for this, but if you've got a link to documentation I didn't find that's fine too. Thanks.
from efcorepowertools.
I just blogged: https://erikej.github.io/efcore/2020/08/10/ef-core-power-tools-stored-procedures.html
from efcorepowertools.
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?
from efcorepowertools.
@intomneato doubt it, maybe because they are not returning results.
Could you share a repro project, with a sample sproc?
from efcorepowertools.
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.
from efcorepowertools.
Please create an issue for this, and I will investigate...
from efcorepowertools.
No problem. Issue #449 created. Thanks for your help, EFCorePowerTools really is very helpful and easy to use!
from efcorepowertools.
Related Issues (20)
- throw new NotSupportedException("This method can only be called from Entity Framework Core queries"); as the definition of a HOT 1
- Add Generate ER Diagram to Project context menu (support for .dacpac)
- [Feature] Add "Analyze this!" to database projects / MsBuild.SDK.SqlProj context menu
- SQL Server table valued functions disappeared HOT 4
- DRY FunctionScaffolder and ProcedureScaffolder
- Hi Erik, While I'm trying to access the Reverse Engineer ... HOT 4
- Table Valued Parameters in Stored Procedures from a .dacpac HOT 23
- Inappropriate Navigation Property name generated by EF Core reverse engg. HOT 5
- Inappropriate Navigation Property name generated by EF Core reverse engg. HOT 9
- [Question] How to disable generation of readme in EF Core Power Tools CLI ? HOT 3
- Analyse this! from a live database (experimental)
- Sync localized vsct files
- Support for Many-to-many and join table with payload HOT 2
- Ability to use migrations tool without providing a connection string HOT 6
- Latest update fails to load. HOT 17
- Check synapse host name detection
- Unable to reverse engineer because it cannot find data provider HOT 1
- [Feature] Map simple postgress stored procedures
- Add script generation to migrations tool HOT 3
- [Question] Compare DbContext to Database Using CLI HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from efcorepowertools.