C
C#3mo ago
SWEETPONY

Error: The value of shadow key property 'ResourceDemandChunks.Id' is unknown when attempting to save

Hey everyone! I'm stuck with this problem: The value of shadow key property 'ResourceDemandChunks.Id' is unknown when attempting to save changes. This is because shadow property values cannot be preserved when the entity is not being tracked. Consider adding the property to the entity's .NET type this is how I register entity in db context:
modelBuilder.Entity<WorkingTaskEntity>().OwnsOne(c => c.CustomData, t =>
{
t.ToJson();
t.OwnsMany(customData => customData.ResourceDemandChunks);
});
modelBuilder.Entity<WorkingTaskEntity>().OwnsOne(c => c.CustomData, t =>
{
t.ToJson();
t.OwnsMany(customData => customData.ResourceDemandChunks);
});
CustomData is jsonb property, in DDL it is jsonb, I absolutely no idea what happening..
public WorkingTaskData? CustomData { get; init; }
public record WorkingTaskData
{
public List<ResourceDemandChunks> ResourceDemandChunks { get; set; }
public WorkingTaskData? CustomData { get; init; }
public record WorkingTaskData
{
public List<ResourceDemandChunks> ResourceDemandChunks { get; set; }
1 Reply
SWEETPONY
SWEETPONYOP3mo ago
The error only appears when I want to update properties in the entity where the ResourceDemandChunks are filled. If I create an entity and fill in ResourceDemandChunks, then everything is fine and there are no errors fixed
Want results from more Discord servers?
Add your server