-
Notifications
You must be signed in to change notification settings - Fork 19
If (Not )Exists checks in migrations (SQL Server)
Pawel Gerr edited this page Nov 11, 2025
·
1 revision
This feature is using SQL Server capabilities.
Register ThinktectureSqlServerMigrationsSqlGenerator with EF.
var services = new ServiceCollection()
.AddDbContext<DemoDbContext>(builder => builder
...
.UseSqlServer("conn-string", sqlOptions =>
{
sqlOptions.UseThinktectureSqlServerMigrationsSqlGenerator();
})Use IfExists or IfNotExists to add checks to operations.
migrationBuilder.CreateIndex("IX_OrderItems_ProductId", "OrderItems", "ProductId").IfNotExists();-
CreateTable-IfNotExists -
DropTable-IfExists -
AddColumn-IfNotExists -
DropColumn-IfExists -
CreateIndex-IfNotExists -
DropIndex-IfExists -
AddUniqueConstraint-IfNotExists -
DropUniqueConstraint-IfExists
The implementation of IMigrationsSqlGenerator will be replaced by ThinktectureSqlServerMigrationsSqlGenerator (derives from SqlServerMigrationsSqlGenerator)
- Collection Parameters (temp-tables light) (SQL Server)
- Window Functions Support (RowNumber, Sum, Average, Min, Max)
- Nested (virtual) Transactions
- Table Hints (SQL Server)
- Queries accross multiple databases (SQL Server)
- Changing default schema at runtime
- If-Exists / If-Not-Exists checks in migrations (SQL Server)
- Migrations: include-columns (SQL Server)
- Migrations: identity column (SQL Server)
- Migrations: (non-)clustered PK (SQL Server)