Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -565,11 +565,17 @@ protected virtual void GenerateComplexProperty(
var complexType = complexProperty.ComplexType;
var complexTypeBuilderName = GenerateNestedBuilderName(builderName);

var propertyType = Code.Reference(Model.DefaultPropertyBagType);
if (complexProperty.IsCollection)
{
propertyType = $"List<{propertyType}>";
}

stringBuilder
.AppendLine()
.Append(builderName)
.Append(complexProperty.IsCollection ? ".ComplexCollection(" : ".ComplexProperty(")
.Append($"typeof({Code.Reference(Model.DefaultPropertyBagType)}), ")
.Append($"typeof({propertyType}), ")
.Append($"{Code.Literal(complexProperty.Name)}, {Code.Literal(complexType.Name)}, ")
.Append(complexTypeBuilderName)
.AppendLine(" =>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6201,7 +6201,7 @@ public virtual void Complex_types_mapped_to_json_are_stored_in_snapshot()
{
b2.Property<string>("Id");

b2.ComplexCollection(typeof(Dictionary<string, object>), "Properties", "Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+EntityWithOneProperty.EntityWithTwoProperties#EntityWithTwoProperties.EntityWithStringKey#EntityWithStringKey.Properties#EntityWithStringProperty", b3 =>
b2.ComplexCollection(typeof(List<Dictionary<string, object>>), "Properties", "Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+EntityWithOneProperty.EntityWithTwoProperties#EntityWithTwoProperties.EntityWithStringKey#EntityWithStringKey.Properties#EntityWithStringProperty", b3 =>
{
b3.Property<int>("Id");

Expand Down Expand Up @@ -6256,6 +6256,7 @@ public virtual void Complex_types_mapped_to_json_are_stored_in_snapshot()
entityWithStringKeyComplexType.FindComplexProperty(nameof(EntityWithStringKey.Properties));
Assert.True(propertiesComplexCollection.IsCollection);
Assert.Equal("JsonProps", propertiesComplexCollection.GetJsonPropertyName());
Assert.Equal(typeof(List<Dictionary<string, object>>), propertiesComplexCollection.ClrType);
});

#endregion
Expand Down
Loading