Bug description
DEFAULT value constraints are applied to columns in history table. Which cause problems in subsequent migrations that affect those columns.
Migration 1: Create table (single entity with a nullable string "Name" property), enable temporal
Migration 2: Make "Name" property non nullable and set default value
Migration 3: Set max-length on "Name" property
EF Core 8.0.12 adds the DEFAULT constraint from migration 2 only to the column in the "regular" table.
EF Core 9.0.2 adds the DEFAULT constraint from migration 2 to the column in the "regular table" and to the column in the history table.
When migration 3 comes along the migration script removes the DEFAULT constraint on the column from the regular table to update the max-length. But does not remove it from the history table. This results in an sql error:
Microsoft.Data.SqlClient.SqlException (0x80131904): The object 'DF__AHistory__Name__5DCAEF64' is dependent on column 'Name'.
ALTER TABLE ALTER COLUMN Name failed because one or more objects access this column.
Your code
[Minimal reproduction](https://github.com/DaanWasscher/efcore9_temporaltable_repro)
Stack traces
Verbose output
EF Core version
9.0.2
Database provider
Microsoft.EntityFrameworkCore.SqlServer
Target framework
.NET 9.0
Operating system
No response
IDE
No response
Bug description
DEFAULT value constraints are applied to columns in history table. Which cause problems in subsequent migrations that affect those columns.
Migration 1: Create table (single entity with a nullable string "Name" property), enable temporal
Migration 2: Make "Name" property non nullable and set default value
Migration 3: Set max-length on "Name" property
EF Core 8.0.12 adds the DEFAULT constraint from migration 2 only to the column in the "regular" table.
EF Core 9.0.2 adds the DEFAULT constraint from migration 2 to the column in the "regular table" and to the column in the history table.
When migration 3 comes along the migration script removes the DEFAULT constraint on the column from the regular table to update the max-length. But does not remove it from the history table. This results in an sql error:
Your code
Stack traces
Verbose output
EF Core version
9.0.2
Database provider
Microsoft.EntityFrameworkCore.SqlServer
Target framework
.NET 9.0
Operating system
No response
IDE
No response