-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Labels
Description
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. - Property bags: Currently the EF Core stack assumes a distinct CLR type is mapped to each distinct entity type (and eventually for complex types) in the entity model and a CLR property for each entity property (minus any shadow property). This could be changed to enable EF to materialize and track simple property bags (e.g. any object that implements
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) - Dynamic aggregates: Allow the entity type to be determined by the set of contained components (Support dynamic aggregates (Entity–component–system) #26123)
- Proper dynamic objects: This refers specifically to supporting entities and complex types in which each specific instance can contain a different set of properties. I anticipate that the most likely path for us to support proper dynamic objects mapped to relational databases could be to serialize the dynamic part of the object into a BLOB or JSON column instead of shredding it into the individual scalar properties. Querying based on standard properties can be enabled and optimized through computed columns and indexing as described in the comments of Native JSON support #2141. Even within this category there are several alternative levels of support which will probably pose different challenges:
- Only scalar properties can differ vs. relationships can also differ
- Whole dynamic objects vs. "open types" (i.e. dynamic properties are added at runtime to a set of predefined properties).
- Property bag representation vs. actual dynamic/ExpandoObject CLR types (the latter can lead to nicer syntax but might be impossible to use in LINQ).
Reactions are currently unavailable