I'm using code first migrations with entity framework. I've got a column that was created a few migrations ago called Amount which is marked as 'required', that stores an integer value. I've now been told, this needs to be a decimal. When I change the datatype in my context and run 'Add-Migration, it creates the migration file as I expect.
When I run Update-Database, it gives me the following error
The object 'DF_Products_ProductsTrack__522F1F86' is dependent on column 'Amount'. ALTER TABLE ALTER COLUMN Amount failed because one or more objects access this column.
I've managed to write some custom SQL to do this manually:
ALTER TABLE Products
DROP CONSTRAINT [DF__Products__ProductsTrack__522F1F86]
GO
ALTER COLUMN Amount decimal(18,2)
However, this is no good as I need the datatype changed as part of my migrations. I am write in assuming the dependency is because of the 'Required' attribute that was initially assigned to it? How do I change the type using 'normal' migration techniques?