对象'DF __ *'依赖于列'*' - 将int更改为double [英] The object 'DF__*' is dependent on column '*' - Changing int to double
问题描述
public int Id {get;组; }
public string标题{get;组; }
public string描述{get;组; }
public string Image {get;组; }
public string WatchUrl {get;组; }
public int Year {get;组; }
public string Source {get;组; }
public int Duration {get;组; }
public int Rating {get;组; }
public virtual ICollection< Category>分类{get;组; }
它工作正常,但是当我将评级的int更改为双精度时,我得到以下错误更新数据库时:
对象'DF_ 电影 _Rating__48CFD27E'依赖于列'评级'。
ALTER TABLE ALTER COLUMN评级失败,因为一个或多个对象访问此列。
有什么问题?
尝试这样:
在更改您的字段之前删除约束 DF_Movies_Rating__48CFD27E 类型。
约束通常由DBMS(SQL 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?
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:
You must remove the constraint before changing the field type.
这篇关于对象'DF __ *'依赖于列'*' - 将int更改为double的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!