【发布时间】:2015-09-02 23:56:45
【问题描述】:
我首先在 SQL Server Management Studio 中设计了我的数据库。
然后使用代码生成实体。
对于表(比如 Product),id 列(比如 ProductID)未设置为身份,因此在实体中,id 属性(比如 ProductID)具有类似的属性
[DatabaseGenerated(DatabaseGeneratedOption.None)].
我把它改成
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
这是我对实体所做的唯一更改。
现在我添加了一个迁移,然后当我Update-Database 时,它会抛出一个错误
Error Number:3728,State:1,Class:16
'PK_dbo.****' is not a constraint.
Could not drop constraint. See previous errors.
知道如何实现这一目标吗?
【问题讨论】:
-
我认为this 是根本问题。
标签: entity-framework ef-code-first entity-framework-migrations