The relevant Entity is as follows:
public class FieldBookingDateRange : ITimeStamps, ICreatedBy, ISoftDeletable
{
[Key, DatabaseGenerated( DatabaseGeneratedOption.None )]
public int FieldBookingDateRangeID { get; set; }
[Required]
public virtual FieldBooking FieldBooking { get; set; }
public virtual DateRange DateRange { get; set; }
....
}
I have a database column that is currently set to Identity: true.
If i run the following auto generated migration on it (This should be setting the column to false on identity):
public partial class RemovedDBGen_FieldBookingDateRange : DbMigration
{
public override void Up()
{
DropIndex("dbo.FieldBookingDateRanges", new[] { "FieldBookingDateRangeID" });
DropPrimaryKey("dbo.FieldBookingDateRanges");
AlterColumn("dbo.FieldBookingDateRanges", "FieldBookingDateRangeID", c => c.Int(nullable: false, identity: false));
AddPrimaryKey("dbo.FieldBookingDateRanges", "FieldBookingDateRangeID");
CreateIndex("dbo.FieldBookingDateRanges", "FieldBookingDateRangeID");
}
public override void Down()
{
DropIndex("dbo.FieldBookingDateRanges", new[] { "FieldBookingDateRangeID" });
DropPrimaryKey("dbo.FieldBookingDateRanges");
AlterColumn("dbo.FieldBookingDateRanges", "FieldBookingDateRangeID", c => c.Int(nullable: false, identity: true));
AddPrimaryKey("dbo.FieldBookingDateRanges", "FieldBookingDateRangeID");
CreateIndex("dbo.FieldBookingDateRanges", "FieldBookingDateRangeID");
}
}
It doesn't do anything... But doesn't fail.
Any ideas why this isn't working?
SQL -Verbose output
IF EXISTS (
SELECT name FROM sys.indexes
WHERE
name = N'IX_FieldBookingDateRangeID' AND
object_id = object_id(N'[dbo].[FieldBookingDateRanges]', N'U')
)
DROP INDEX [IX_FieldBookingDateRangeID] ON [dbo].[FieldBookingDateRanges]
ALTER TABLE [dbo].[FieldBookingDateRanges] DROP CONSTRAINT [PK_dbo.FieldBookingDateRanges]
ALTER TABLE [dbo].[FieldBookingDateRanges] ALTER COLUMN [FieldBookingDateRangeID] [int] NOT NULL
ALTER TABLE [dbo].[FieldBookingDateRanges] ADD CONSTRAINT [PK_dbo.FieldBookingDateRanges] PRIMARY KEY ([FieldBookingDateRangeID])
CREATE INDEX [IX_FieldBookingDateRangeID] ON [dbo].[FieldBookingDateRanges]([FieldBookingDateRangeID])