efcore
efcore copied to clipboard
EF core 7 JSON column gives error for List<Guid>
"The entity type 'List' requires a primary key to be defined"
After configuring the JSON column setup I get the following error "The entity type 'List
Here is my entities
public class CheckpointJSON
{
public ActivityJSONDto JsonData { get; set; }
}
public class ActivityJSONDto
{
public List<ResponseCollectionDto> ActivityDetailJson { get; set; }
}
public class ResponseCollectionDto
{
public List<GotoConditionDto> GotoConditions { get; set; } = new();
}
public class GotoConditionDto
{
public string GotoAnswer { get; set; }
public List<Guid> Goto { get; set; } = new();
}
here is the model builder
modelBuilder.Entity< CheckpointJSON >()
.OwnsOne(c=> c.JsonData,
builder=>
{
builder.OwnsMany(AC => AC.ActivityDetailJson,
bu =>
{
//bu.Property(c => c.GotoConditions);
bu.OwnsMany(c => c.GotoConditions
, builder =>
{
builder.ToJson();
}
);
bu.Property(c=>c.ResponseCustomTypeId).HasConversion<int>();
bu.OwnsMany(c => c.ResponseOptions,b=>
{
//b.HasKey(c => c.ResponseOptionDtoId);
});
bu.OwnsMany(c => c.InspectionResult,builder =>
{
builder.OwnsMany(c => c.CollectionOptionDtos);
builder.OwnsMany(c => c.ImageCollectionDtos);
builder.ToJson();
});
bu.ToJson();
});
builder.ToJson();
});
Duplicate of #31364