Can't use new created columns in SQL - Statement in Up() Migration [DNET811] #746
Submitted by: Andreas Patock (apatock)
If I have the following migration:
public partial class AddDeviceType : DbMigration
I can a Column unknown "DeviceTypeId" exception when running the migration. This can found on many examples in the internet and is working with mssql.
I had the idea to do this in two migrations, but the "DeviceTypeId" is a not null field and so the first migration throws an exception also.
The text was updated successfully, but these errors were encountered:
Commented by: Andreas Patock (apatock)
Do you mean this?
ALTER TABLE "Device" DROP CONSTRAINT "FK_ManDevManId"
The Error is:
Dynamic SQL Error
Commented by: @cincuranet
For not null columns the default value is generated (even if you haven't specified it), see "ALTER TABLE "Device" ADD "DeviceTypeId" INT DEFAULT 0 NOT NULL ". The whole migration is executed in a transaction, the update doesn't see yet the table, because of how DDL and DML inside same transaction work in Firebird.
Not sure provider can do much here. I think the best bet is to split this to two migrations.