I have Entity Framework object model with inheritance.
My linq query:
Books.ItemsNoTracking.Where(o => o.Id == new Guid("2D46B66E-64CB-4C99-AF94-5C7414048ECF")).First();
Expected query:
SELECT * FROM [dbo].[Books] AS [Extent1]
WHERE cast('2d46b66e-64cb-4c99-af94-5c7414048ecf' as uniqueidentifier) = [Extent1].[Id]
But EF generate:
SELECT
[Limit1].[C1] AS [C1],
[Limit1].[Id] AS [Id],
[Limit1].[Created] AS [Created],
[Limit1].[OwnerId] AS [OwnerId],
[Limit1].[Deleted] AS [Deleted],
[Limit1].[PhysicalUnitId] AS [PhysicalObjectId]
FROM ( SELECT TOP (1)
[Extent1].[Id] AS [Id],
[Extent1].[PhysicalObjectId] AS [PhysicalObjectId],
[Extent2].[Created] AS [Created],
[Extent2].[OwnerId] AS [OwnerId],
[Extent2].[Deleted] AS [Deleted],
'0X0X' AS [C1]
FROM [dbo].[Books] AS [Extent1]
INNER JOIN [dbo].[Objects] AS [Extent2] ON [Extent1].[Id] = [Extent2].[Id]
WHERE cast('2d46b66e-64cb-4c99-af94-5c7414048ecf' as uniqueidentifier) = [Extent1].[Id]
) AS [Limit1]
It's most simple example. Other queries are too big and hard to read.
Is there any way to ignore inharitance and create simple query to only one table.