This project is read-only.

Changing column types in migrations

Topics: General, Troubleshooting, Writing modules
Feb 16, 2015 at 3:29 PM
I have a column in my database that is typed as an int and need to be changed to double. Here is what I was hoping would work but didn't
 public int UpdateFrom4()
            table =>
                table.AlterColumn("ColumnName", column => column.WithType(DbType.Double));

        return 5;

It would be nice to be able to do this without dropping the column and re-adding it, if you have any suggestions or input it will be appreciated.
Feb 17, 2015 at 4:48 AM
I think dropping and re-adding is the only way.
Feb 17, 2015 at 5:24 PM
Well that will work for sure, I just didn't want to lose the data I have in the column in the process.
Feb 20, 2015 at 5:09 PM
IIRC this is because SQL CE has a related limitation. Probably it even works with SQL Server... Any way, I think there is a bug report about this.
Feb 20, 2015 at 5:11 PM
Well, not, it's about changing column names, but maybe related: and
Feb 20, 2015 at 6:09 PM

You think its a bug if I cannot change the column type? I am working with SQL server.
Feb 20, 2015 at 6:15 PM
Not a bug but a missing feature. I just though it was already reported but as it seems it wasn't, only the column name change.