-
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 JSON columns in compiled models #30254
Conversation
var jsonColumnName = entityType.GetContainerColumnName()!; | ||
var jsonColumnTypeMapping = (entityType.GetViewOrTableMappings().SingleOrDefault()?.Table | ||
?? entityType.GetDefaultMappings().Single().Table) | ||
.FindColumn(jsonColumnName)!.StoreTypeMapping; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AndriySvyryd I'm not sure if this is right. Should it just look on the DefaultMappings? Does the column need to be added to both the table mappings and the default mappings? If so, what's the appropriate way to do this? Should it be the same column instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default mapping is currently used for FromSql
, so yes, the column should be added to the default mapping also
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you should decide whether to use Table, View or default mapping based on what mapping is being used for the container entity type
var jsonColumnTypeMapping = targetEntityType.GetContainerColumnTypeMapping()!; | ||
var jsonColumnTypeMapping = (entityType.GetViewOrTableMappings().SingleOrDefault()?.Table | ||
?? entityType.GetDefaultMappings().Single().Table) | ||
.FindColumn(jsonColumnName)!.StoreTypeMapping; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question here.
@maumar @AndriySvyryd As I understand it, query won't use the default mapping unless there is no table or view mapping. Do we have existing query tests for the default mapping? (Presumably, FromSql tests where the entity type is explicitly not mapped to a table or view?) If so, where? |
9166ddc
to
4b56e9b
Compare
@AndriySvyryd @maumar Updated to store the container column in the default mapping. |
|
@@ -97,7 +99,7 @@ public virtual Type ProviderClrType | |||
/// doing so can result in application failures when updating to a new Entity Framework Core release. | |||
/// </summary> | |||
public virtual RelationalTypeMapping StoreTypeMapping | |||
=> PropertyMappings.First().TypeMapping; | |||
=> _storeTypeMapping ?? PropertyMappings.First().TypeMapping; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Store the result in _storeTypeMapping
Fixes #29602 The main change here is to store the JSON type mapping in the relational model, and obsolete the previous storage in the underlying EF model.
4b56e9b
to
f73a22e
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Fixes #29602
The main change here is to store the JSON type mapping in the relational model, and obsolete the previous storage in the underlying EF model.