You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Shared-type entities (part of property bag entities) #9914
There are entity types that don't have a natural mapping to a CLR type, either because they aren't part of the domain model (e.g. many-to-many join types) or because the CLR types are inaccessible (e.g. migration snapshot). While these could be mapped to shadow entity types #749 that would make working with them harder as they are tightly coupled to the state manager and would need special case handling throughout the stack, especially in the query pipeline.
Property bag entity types are still fully specified at model building time, dynamic types are tracked by #2282. The basic implementation would add support for entities backed up by a Dictionary<string, object> with a predefined entry that contains the entity type name.
Usage:
modelBuilder.Entity("Cat", c =>{c.Property<int>("Id");c.Property<string>("Name");});
context.Add(newDictionary<string,object>{{"Entity type name","Cat"},{"Id",123},{"Name","Tabby"}});
Reacted by Michael Ovchinnikov, Lucas Teles , Yuze, Alexander Herold, Halid Cisse, Maxim, Victor Lee, Soheil Alizadeh, Erik O'Leary, Shimmy Weitzhandler and 2 more
This issue seems like slight duplication of #2282. I would like repeat myself saying this feature will be very helpful to implement F# type provider for EF Core. Please, consider bumping up priority. Thanks.
@dmitry-a-morozov#2282 is about property bag properties, but this one is about property bag entities, which might or might not contain property bag properties
@AndriySvyryd Thanks for clarification. I think I'm interested in this one then. I know statement about F# can be confusing. Let me know if you need more information on why it's helpful for F#.
@dmitry-a-morozov I believe this would be useful in combination with F# type providers because when the design-time generated types are erased, property bags could act as the runtime type. Is this what you had in mind?
@AndriySvyryd when I wrote the text about property bags in #2282 I was specifically talking about "property bag entities":
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.
So I am still wondering what you mean when you say these are about two different things 😄
Anyway, I think it is fine to track property bag entities separately here because #2282 is a meta-issue.
@divega Great ! I'm glad you're familiar with F# and we're on the same page.
Once it's done F# community can start working on type providers for EF Core.
Also, consider working with IDictionary<string, object> interface as oppose to Dictionary<string, object> class so diff implementation can be supplied for example ExpandoObject.
Also, consider working with IDictionary<string, object> interface as oppose to Dictionary<string, object> class...
FWIW, I think it could be interesting to support arbitrary types that have an indexer of the right shape rather than requiring a specific type, i.e. pattern match the indexer, but not sure how much more complicated this would be.
@dmitry-a-morozov there is a possibility that we will do it in 2.1 or soon after, driven by other features like many-to-many without a join entity, but I wouldn't build plans around it just yet.
@cartermp why don't we try to come up together with a plan to have EF Core work better with F#? Then we can use that to decide the priority of individual issues. I get how this one can help, however there is also #10731, which makes me wonder if we are missing the whole point 😄
Activity
ajcvickers commentedon Oct 4, 2017
Putting this on the backlog for now; we may pull it in if it is needed for some other 2.1 feature, such as if we allow seeding using navigations.
dmitry-a-morozov commentedon Oct 15, 2017
This issue seems like slight duplication of #2282. I would like repeat myself saying this feature will be very helpful to implement F# type provider for EF Core. Please, consider bumping up priority. Thanks.
AndriySvyryd commentedon Oct 15, 2017
@dmitry-a-morozov #2282 is about property bag properties, but this one is about property bag entities, which might or might not contain property bag properties
dmitry-a-morozov commentedon Oct 15, 2017
@AndriySvyryd Thanks for clarification. I think I'm interested in this one then. I know statement about F# can be confusing. Let me know if you need more information on why it's helpful for F#.
divega commentedon Oct 16, 2017
@dmitry-a-morozov I believe this would be useful in combination with F# type providers because when the design-time generated types are erased, property bags could act as the runtime type. Is this what you had in mind?
@AndriySvyryd when I wrote the text about property bags in #2282 I was specifically talking about "property bag entities":
So I am still wondering what you mean when you say these are about two different things 😄
Anyway, I think it is fine to track property bag entities separately here because #2282 is a meta-issue.
dmitry-a-morozov commentedon Oct 16, 2017
@divega Great ! I'm glad you're familiar with F# and we're on the same page.
Once it's done F# community can start working on type providers for EF Core.
dmitry-a-morozov commentedon Oct 16, 2017
Also, consider working with
IDictionary<string, object>interface as oppose toDictionary<string, object>class so diff implementation can be supplied for exampleExpandoObject.AndriySvyryd commentedon Oct 16, 2017
@divega @dmitry-a-morozov Oops, I was thinking about #2968
divega commentedon Oct 17, 2017
@AndriySvyryd makes sense. Yep, #2968 is closely related too.
FWIW, I think it could be interesting to support arbitrary types that have an indexer of the right shape rather than requiring a specific type, i.e. pattern match the indexer, but not sure how much more complicated this would be.
dmitry-a-morozov commentedon Oct 19, 2017
@divega @AndriySvyryd Any chance you can consider this for 2.1?
divega commentedon Oct 19, 2017
@dmitry-a-morozov there is a possibility that we will do it in 2.1 or soon after, driven by other features like many-to-many without a join entity, but I wouldn't build plans around it just yet.
cartermp commentedon Jan 29, 2018
@divega since 2.1 is winding down, is this something we could get on the docket for 2.2?
divega commentedon Feb 12, 2018
@cartermp why don't we try to come up together with a plan to have EF Core work better with F#? Then we can use that to decide the priority of individual issues. I get how this one can help, however there is also #10731, which makes me wonder if we are missing the whole point 😄
62 remaining items
Use FindEntityType(Type) as appropriate (#21639)
Add public APIs to configure shared type entities
Add public APIs to configure shared type entities
Add public APIs to configure shared type entities
Add public APIs to configure shared type entities (#21552)