Sql – The object ‘DF__*’ is dependent on column ‘*’ – Changing int to double

databaseentity-frameworkentity-framework-4sqlsql server

Basically I got a table in my EF database with the following properties:

public int Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string Image { get; set; }
public string WatchUrl { get; set; }
public int Year { get; set; }
public string Source { get; set; }
public int Duration { get; set; }
public int Rating { get; set; }
public virtual ICollection<Category> Categories { get; set; }

It works fine however when I change the int of Rating to be a double I get the following error when updating the database:

The object 'DF_Movies_Rating__48CFD27E' is dependent on column 'Rating'.
ALTER TABLE ALTER COLUMN Rating failed because one or more objects access this column.

What's the issue?

Best Answer

Try this:

Remove the constraint DF_Movies_Rating__48CFD27E before changing your field type.

The constraint is typically created automatically by the DBMS (SQL Server).

To see the constraint associated with the table, expand the table attributes in Object explorer, followed by the category Constraints as shown below:

Tree of your table

You must remove the constraint before changing the field type.

Related Topic