Does an EntityFrameworkCore.SQLServer.InMemory Assembly exist?

Jack Allread 11 Reputation points
2022-04-14T17:12:00.743+00:00

Hello,

We have a web app that utilizes micro-frontends and we are also utilizing Temporal tables in SQL Server.
I have just written the first API accessing a Temporal table and it ran fine (once I realized there is a EntityFrameworkCore.SQLServer assembly).
However, when I wrote the UnitTest for it using Moq it failed with an Exception. If I remove the Temporal Extensions the UnitTest runs and passes file. The UnitTest project uses EntityFrameworkCore.InMemory, however, I cannot find the assembly EntityFrameworkCore.SQLServer.InMemory which is what I think I need to solve the problem.

I have a sample application that shows the result, but didn't see a way to upload it.

Any information or data you can provide would be appreciated.
Best,
Jack

PS The exception is:
System.InvalidCastException : Unable to cast object of type 'System.Linq.Expressions.ConstantExpression' to type 'Microsoft.EntityFrameworkCore.Query.QueryRootExpression'. I have tried the reform the linq in the EF many different ways to no avail, however, removing the Temporal Tabke extensions allows the UnitTest to run without an exception.

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
702 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,895 questions
Visual Studio Testing
Visual Studio Testing
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Testing: The act or process of applying tests as a means of analysis or diagnosis.
331 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Jack Allread 11 Reputation points
    2022-04-15T14:32:31.193+00:00

    Here is the function under test. It runs fine from the app.

     public async Task<Dictionary<String, String>> LookupPrices(IOrdersContext context, string productName, DateTime from, DateTime to)
        {
            var result = new Dictionary<String, String>();
    
            var productSnapshots = await context.Products
                .TemporalFromTo(from, to)
                .OrderBy(product => EF.Property<DateTime>(product, "PeriodStart"))
                .Where(product => product.Name == productName)
                .Select(product =>
                    new
                    {
                        Product = product,
                        PeriodStart = EF.Property<DateTime>(product, "PeriodStart"),
                        PeriodEnd = EF.Property<DateTime>(product, "PeriodEnd")
                    })
                .ToListAsync();
    
            foreach (var snapshot in productSnapshots)
            {
    
                result.Add(snapshot.Product.Name, snapshot.Product.Price.ToString());
            }
    
            return result;
        }
    
    1 person found this answer helpful.