Define inheritance hierarchy as stated in the limitations
Filters can only be defined for the root Entity Type of an inheritance hierarchy .
Please define inheritance hierarchy and provide a simple example of the limitation. Thanks!
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: b7c9bd3e-4b99-9acf-48d8-e47bc53eb54e
- Version Independent ID: 220e0a6c-d227-956a-d27a-7c88804f770c
- Content: Global Query Filters - EF Core
- Content Source: entity-framework/core/querying/filters.md
- Service: unspecified
- Product: entity-framework
- GitHub Login: @anpete
- Microsoft Alias: anpete
@markarnolditpro It just means mapped classes that use normal class inheritance:
public class Document
{
}
public class Blog : Document
{
}
If Document and Blog are mapped, then the filter can only be applied to Document, not to Blog.
Is there a "Global Query Projector" ? to include or exclude some table fields ? If I have a column for each culture of a localized field I would use such a global option to select the correct field according to current selected culture.
I have an EF Core set of entities where each entity inherits from a BaseEntity, which contains some shared global properties (Id, IsDeleted, etc). By default, this gets mapped to a Azure SQL database as Table per Concrete Type which is great.
However, when I add a query filter as per the example:
modelBuilder.Entity<BaseEntity>().HasQueryFilter(p => !p.IsDeleted);
on the next migration EF wants to drop all my tables and create a single table called BaseEntity which is the Table Per Hierachy pattern.
Is this expected behaviour? Any way to avoid it?
EDIT: This is happening because modelBuilder.Entity