-
-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
Trying to insert an entity graph that includes owned entities results in an exception.
Postgres
EF Core 8
At some point this expression is attempted to be executed:
SELECT b.id, b.bar_content, b.foo_id, b0.id, b0.zap_content
FROM INSERT INTO "analytics"."bars" ("bar_content", "foo_id", "zap_content")
(SELECT "bar_content", "foo_id", "zap_content" FROM "analytics"."barsTemp668b8ac8")
ON CONFLICT ("id") DO UPDATE SET "bar_content" = EXCLUDED."bar_content", "foo_id" = EXCLUDED."foo_id", "zap_content" = EXCLUDED."zap_content"
RETURNING "id", "bar_content", "foo_id", "zap_content"
LEFT JOIN analytics.bars AS b0 ON b.id == b0.id
it looks like "b" alias is being used without being defined.
Exact error:
'FromSql' or 'SqlQuery' was called with non-composable SQL and with a query composing over it. Consider calling 'AsEnumerable' after the method to perform the composition on the client side.
Here are the entities:
public class Foo {
public long Id { get; set; }
public AssetType AssetType { get; set; }
public ICollection<Bar> Bars { get; set; } = null!;
}
public class Bar {
public long Id { get; set; }
public long FooId { get; set; }
public Foo Foo { get; set; } = null!;
public string BarContent { get; set; } = null!;
public Zap Zap { get; set; } = null!; // Zap is owned by Bar. Using .OwnsOne configuration.
}
public class Zap {
public string ZapContent { get; set; } = null!;
}
inlining ZapContent in Bar (identical DB schema) solves the issue.
Metadata
Metadata
Assignees
Labels
No labels