Is it possible to alter tables in code-first migrations with nocheck constraints? I haven’t found any way to do this except of getting SQL script via Update-Database -Script and modifying the sql statements.
Is it possible to alter tables in code-first migrations with nocheck constraints? I haven’t
Share
You can try creating your own
MigrationSqlGeneratorand use it with migrations (you can set custom SQL generator inDbMigrationsConfiguration) – I think it should be enough to inheritSqlServerMigrationSqlGeneratorand addNOCHECKafter adding foreign key = overridingGenerate(AddForeignKeyIperation operation).Anyway using
NOCHECKwith EF is way to disaster. If you want to have database without checked constraints don’t use EF because it will crash every time it reaches inconsistency.