New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error With Temporals using InMemory Provider #27587
Comments
Temporal tables are a feature of SQL Server, and are not supported in the InMemory provider. I'd recommend reading this doc page on the different testing strategies - we generally discourage using the InMemory provider. |
We're not trying to test our Database/Connection, we just need a way to check that the logic operates in our codebase via unit tests. I'd be perfectly fine with a solution that ignores the temporal configuration altogether for inmemory, so long as it doesn't throw an error because of the configuration. Just to reiterate, this is for Unit Testing and in no way are we relying on it for persistence or context maintenance. |
@gafken Why do you need to use the in-memory provider for that? |
@gafken you can add the missing temporal properties as shadow properties only for InMemory by doing a provider check when configuring the model, e.g.: protected override void OnModelCreating(ModelBuilder modelBuilder)
{
if (Database.IsInMemory())
{
modelBuilder.Entity<SomeEntityType>(b =>
{
b.Property<DateTime>("SysStart");
b.Property<DateTime>("SysEnd");
});
}
} |
@roji That solved my issue, thanks a bunch! :) |
Is that acceptable? Those files need to be overwriteable and autogenerated; right? |
@bluebaroncanada If you're scaffolding the DbContext code, then use the partial method instead. |
Thanks @gafken, this worked for me as well. One side note, I had to add this code before: base.OnModelCreating(modelBuilder); Saved my day. |
When I'm using the InMemory Provider for EfCore 6.0 it keeps telling me that 'Example.SysStart' cannot be found. That's actually accurate as SysStart only exists on the ExampleHist Table. With the standard SQL Provider we run into no issues running our configuration. If I add the properties to the entity the InMemory Provider works fine but the SQL Provider complains that a shadow property cannot be explicitly defined.
and
The text was updated successfully, but these errors were encountered: