对象“DF __ *”依赖于列'*' - 将int更改为double [英] The object 'DF__*' is dependent on column '*' - Changing int to double

查看:2552
本文介绍了对象“DF __ *”依赖于列'*' - 将int更改为double的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我在我的EF数据库中有一个表,具有以下属性:

  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;组; }

它工作正常,但是当我将Rating的int改为double我得到以下错误更新数据库时:



对象'DF_ 电影 _Rating__48CFD27E'取决于列'评级'。
ALTER TABLE ALTER COLUMN评分失败,因为一个或多个对象访问此列。



问题是什么?



在更改字段类型之前,请删除约束DF_Movies_Rating__48CFD27E。

$

b
$ b

约束是由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 has created automatically by DBMS (Sql Server).

To show your constraint in your table show this:

in this tree you have constraints of your table. You must remove it before change your field type.

这篇关于对象“DF __ *”依赖于列'*' - 将int更改为double的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆