In "Code First" EF approach, I've changed the type of a property:
Before:
DateTime Date { get; set; }
After:
DateTimeOffset Date { get; set; }
And then I executed (Package Manager Console):
Add-Migration Foo
Which created this code:
public partial class Foo : DbMigration
{
public override void Up()
{
AlterColumn("dbo.Foos", "Date", c => c.DateTimeOffset(nullable: false, precision: 7));
}
public override void Down()
{
AlterColumn("dbo.Foos", "Date", c => c.DateTime(nullable: false));
}
}
But this is not working when executing the update (Package Manager Console):
Update-Database
Error:
Error Number:5074,State:1,Class:16 The object 'DF__Foo__2B2A60FE' is dependent on column 'Date'. ALTER TABLE ALTER COLUMN Date failed because one or more objects access this column.
How can I solve this? I'm not referencing this column in other parts (there are no indexes)
As Ivan Stoev said in the comments, this is fixed by updating to EF 6.2 (I was using EF 6.1.3)