-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Improved view support #827
Comments
@ilmax - At this early stage of the project this isn't something we want to take just yet (as we're still heavily iterating on the core of the product). You could do this as an external add-on to EF and we would definitely be open to considering taking it a little further down the road. |
Hi @rowanmiller, does the team is interested in such contribution? I would like to be able to query views with EF, and would love to give my contribution on this feature. If this is something the team can be interested in, I would like to start a discussion around the needed changes and the general direction to take. Regards, Max. |
I agree with Max, this would be an excellent feature. It would be even cooler if we could use linq to define indexed views. |
Without view support EF Core is almost useless as, I'm sorry to say, the query generator does not have enough intelligence for supporting high performant business applications with 10 or more joins, unions and complex "group by" statements on applications with millions of records. And some databases just all ready have good views on board. ICT work is often about modernizing gui's on old databases. |
@ilmax care to share how you are mapping views and generating migrations for them? |
@staff0rd my prototype was build against early EF Core version, since ef was in the early days at the time, I abandoned the prototype, waiting for EF Core to RC. |
@ilmax any update, EF Core is RC already... :) |
@gdoron Since EF Core is a completely new rewrite, over the time a lot of parts have changed so my POC is not working anymore, I plan to work on this as soon as EF Core reaches RTM |
@ilmax I think since EF is RC already there won't be as much changes as when it was Alpha/beta. But regardless, once you contributed the code and it was merged, it's in the repository, and if the EF team will do a breaking change that break the view generation (not a likely scenario since RC), they will have to fix it, so I wouldn't be too much worry about it. |
BTW in the meantime you can just tell EF that the view is a table. The limitations of this approach are that you need to give EF some properties to use as a key, and migrations won't create a view for you. You can also use raw SQL to select from a view |
This is true, but the feature needs to be completely implemented (including tests etc.) for us to take the code. |
@rowanmiller but how can I trick EF not to try and create the table (which is a view) in the migrations?
This will work only if the view returns data from a single table, if it's (like in 99% of the times) a view that returns data from multiple composed tables, we'll get only the data from the Blogs, the columns from Users let's say will be ignored when deserialized.
You reminded me an old jewish joke I heard 10 years ago. :) |
Yes, that is what you would need to do |
@rowanmiller I don't see VIEWs support in the roadmap at all. Thanks |
We just missed it off the list, I've added it to the roadmap. |
@rowanmiller You might want to add a link in the roadmap to this PR for how it can be done in the meanwhile: #4561 so people won't think there's absolutely no way of doing it. Thanks |
@rowanmiller great to see it's on the roadmap! Kutgw |
Has this issue been targeted for a release yet? We are currently having to maintain two database catalogs for code generation. We have one database that contains table schema only to represent the views that exist in our actual database. Vance |
Happy this is on the roadmap, it's hard to justify EF Core usage without DBFunctions and views. |
Do you have any release date for supporting views? |
For the record, I'll add a "Me, too!" comment here. Please can you prioritize View support? |
One of the big things folks want when working with views is to be able to query data into objects that are not entities (and therefore the view doesn't have to be normalized or have a key). We expect to at least make progress on that feature in 2.0 (#1862). |
When can we hope to see it done? |
@BillieBishop Did you see #4561 ? |
I agree with many others here - view support is critically important - please try to get it in the next release. The lack of view support is especially painful given that there are also issues with doing projections on related objects - #5738 and #7131. Unless there is something I am missing - at this point the only efficient way to do a query that joins a bunch of entities and selects a minimal number of fields is to pass raw SQL (i.e. - SqlQuery function). |
Me too |
@ajcvickers any news about this? It is added to backlog, but I can't find any information about any progress. |
@Misiu When an issue is in the backlog it means that the EF team is intending to work on it at some point in the future, but is not actively working on it now--that's what the "backlog" is. For this issue specifically, there are several sub-issues, one of which is being worked on for 2.1--#9290. I believe the other sub-issues are also still in the backlog. |
I'm just here to add a "me too" to indicate that there is still interest in this feature. |
going 5 years. |
As i see this will be one of the new feature in ef core 3 |
In 3.0 we have completed some of the most important aspects of this "aggregate issue" on database view support. Adding propose-close because I think its existence gets in the way of figuring out the relative priority of the remaining issues and even possibly of figuring out other important aspects of view support that are missing. As far as I know, all the remaining aspects that we know about are being tracked by its own independent issues in the backlog. We could alternatively choose to make this a discussion issue, but I don't think those have proven very useful. |
After trying it out, #9290 covers views well. |
Please, have a look there: https://github.com/DarioN1/SPToCore I have created a kind of scaffolder for Stored Procedure, I'm using it in a new project that uses an existing database with more than 300 stored procedures. |
This is a meta-issue covering the different aspects of support for mapping to and using views in EF Core. Different parts of this support will be done at different times, so while this issue may be in the Backlog, the individual issues below contain the status for various aspects of view support.
Please consider voting 👍 for one of the issues above rather than for this overall issue, since that will provide more specific and actionable feedback about the relative importance of different aspects of view support.
Original issue text:
The text was updated successfully, but these errors were encountered: