-
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
Support for "dynamic" entity models #2282
Comments
Moving this straight to the backlog. |
Hello, just a thought on this, instead of DB first there could be a JSON or even XML first equivalent. |
This would help with materializing var post = context.Posts.First();
var entry = context.Entry(post);
var isDraft = entry.Property("IsDraft").CurrentValue as bool;
post.AddAnnotation("IsDraft", isDraft); Of course this has caveats: AFAIK the only way to get a shadow property value after materialization is to use change tracking. This means to |
Are there plans to make a progress on this feature request? |
Triage: Consider scenario described here when tackling this issue: #10555 |
Dynamic functionality is very essential in almost any growing app, especially LoB apps or apps that grow quickly and dynamically. Let me just demonstrate with a couple of examples using a
var number = CleanNumber(number); //remove formatting
dbContext.Contacts
.Where(c =>
c.Phones.Where(p => p.Label = "Work" && p.Number.Contains(number)); Remember that we don't want to predefine the phone shape in the DB (only in the EF back-end).
Let's take Microsoft SQL Server as our DB provider. It provides out the box support for that using JSON/XML |
@weitzhandler - I was reading this thread. While dynamic entity types has a wide scope, I believe the scenario you posted could possibly work in current system already. |
In the future, this (especially the queryability) has to be implemented in the system with no need for |
@weitzhandler - Of course, functions related to JSON support on query side would be implemented in #4021 XML could achieve the similar. This also have some overlap with property bag entities. Regardless, most of work here would be about changing the metadata for representation. Query side comes into picture depending on how it is stored on server & what we can translate. |
Note from triage: remaining work here tracked by related issues. |
The goal of this issue is to track and rationalize various levels or flavors of "dynamic behavior" we could attain with EF in the future.
The initial list is based on digesting information provided in various bugs such as #1513 and #2141 as well as conversations with various teams and previous research on feature gaps with other persistence frameworks.
Note that none of this is planned for EF Core 1.0.0 and before we start bringing dynamic features into EF we should probably open more issues and prioritize each individual feature independently. But at least for now should any new "dynamic" scenario be brought to our attention by the community or should our understanding of them improve we can just keep this list up to date:
Shadow objects: (already tracked individually as Fully implement entire entities in shadow state #749) This is about having certain entities or complex types defined in the model that do not get materialized as user objects but are just tracked as "state" in the DbContext instance. This is useful for such scenarios as link tables in many-to-many associations or any other situation in which there is an entire entity that contains information that EF needs to track but that the user has chosen not to include in the object model.IDictionary<string, object>
or contains an indexer property or any other mechanism to get and set values based on a property name). Even the name of the entity instance belongs to could become another property in the bag. This feature would make working with entity models that are created programmatically easier because it would remove the need to emit new CLR types for each entity and complex type at runtime. (Shared-type entities (part of property bag entities) #9914)The text was updated successfully, but these errors were encountered: