From 37b3840a7c40611915b80ea1bb64d441ab70f15e Mon Sep 17 00:00:00 2001 From: Joakim Riedel Date: Fri, 9 Jul 2021 22:12:00 +0200 Subject: [PATCH] Add a note on querying shared columns --- entity-framework/core/modeling/inheritance.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/entity-framework/core/modeling/inheritance.md b/entity-framework/core/modeling/inheritance.md index edbae9d9f7..60781b2331 100644 --- a/entity-framework/core/modeling/inheritance.md +++ b/entity-framework/core/modeling/inheritance.md @@ -55,6 +55,9 @@ By default, when two sibling entity types in the hierarchy have a property with [!code-csharp[Main](../../../samples/core/Modeling/FluentAPI/SharedTPHColumns.cs?name=SharedTPHColumns&highlight=9,13)] +> [!NOTE] +> Relational database providers, such as SQL Server, will not automatically use the discriminator predicate when querying shared columns when using a cast. The query `Url = (blob as RssBlog).Url` would also return the `Url` value for the sibling `Blog` rows. To restrict the query to `RssBlog` entities you need to manually add a filter on the discriminator, such as `Url = blob is RssBlog ? (blob as RssBlog).Url : null`. + ## Table-per-type configuration > [!NOTE]