-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Entity Framework Core 3.1 with Temporal Tables - Access SysStartTime and SysEndTime #23184
Comments
@Ogglas EF Core should work fine mapping those properties to your existing temporal table, since it has has those columns created automatically. However, EF migrations do not know that these columns already exist, so if you add properties to your model, then migrations is going to try create columns for you. You should be able to just edit the migration and remove the code that creates the columns. |
@ajcvickers Thanks! For tables that already had the columns I simply removed
I do not want to edit default code generated by migrations later on so I decided to do it like this for new entities: Add
ApplicationDbContext.cs:
Migration, if you already have
Question on Stackoverflow: https://stackoverflow.com/q/64653497/3850405 |
I have created temporal tables based on Microsoft SQL Docs Creating a temporal table with a default history table.
https://docs.microsoft.com/en-us/sql/relational-databases/tables/creating-a-system-versioned-temporal-table?view=sql-server-ver15#creating-a-temporal-table-with-a-default-history-table
Migration:
Complete example how Temporal tables was set up:
https://stackoverflow.com/a/64244548/3850405
This works really well but now I want to access the value for
SysStartTime
.What I have tried:
ApplicationDbContext.cs:
and
Every migration leads to the following:
This of course leads to the error below on
Update-Database
command:I have been reading both these questions and it seems to have been working in Entity Framework Core 2.2:
https://stackoverflow.com/q/62379060/3850405
https://stackoverflow.com/q/42627585/3850405
Tried disabling HIDDEN but it did not help
SQL:
Include provider and version information
EF Core version: 3.1.6
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 3.1
Operating system: Windows 10 Enterprise X64, OS Build 19041.572
IDE: Visual Studio 2019 16.7.7
The text was updated successfully, but these errors were encountered: