InvalidOperationException: 'Set operation can't be applied on entity 'Customer' because temporal operations on both arguments don't match.'
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
I've a temporal table: Customers
I would like to get the delta between t1 and t2 using the TemporalAsOf . (I need new or modified items created since t1).
```context.Customers.TemporalAsOf(t2).Except(context.Customers.TemporalAsOf(t1)).ToList();```
Which I would expect to be translated to something like:
SELECT [c].[Id], [c].[Name], [c].[PeriodStart], [c].[PeriodEnd]
FROM [Customers] FOR SYSTEM_TIME AS OF 't2' AS [c]
EXCEPT
SELECT [c].[Id], [c].[Name], [c].[PeriodStart], [c].[PeriodEnd]
FROM [Customers] FOR SYSTEM_TIME AS OF 't1' AS [c]
But I get the following exception:
System.InvalidOperationException: 'Set operation can't be applied on entity 'Customer' because temporal operations on both arguments don't match.'
Stacktrace:
```
System.InvalidOperationException: 'Set operation can't be applied on entity 'Customer' because temporal operations on both arguments don't match.'
at Microsoft.EntityFrameworkCore.SqlServer.Query.Internal.SqlServerNavigationExpansionExtensibilityHelper.AreQueryRootsCompatible(QueryRootExpression first, QueryRootExpression second)
at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.ValidateExpressionCompatibility(Expression outer, Expression inner)
at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.ProcessSetOperation(NavigationExpansionExpression outerSource, MethodInfo genericMethod, NavigationExpansionExpression innerSource)
at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.Expand(Expression query)
at Microsoft.EntityFrameworkCore.Query.QueryTranslationPreprocessor.Process(Expression query)
at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass9_0`1.b__0()
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Program.<>c.<$>b__0_11(DateTime fromUtc, DateTime toUtc, OrdersContext context) in C:\wvltemp\TemporalTables\TemporalTables\Program.cs:line 82
at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
```
EF Core version: 7.0.0-preview.7.22376.2
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .net 7.0
Operating system: Windows 10
IDE: (Visual Studio 2022 Version 17.4.0 Preview 1.0
Contributor guide
Assessment
This issue has not been assessed yet.