本文介绍了EF CodeFirst:参数@objname是不明确的或声明的@objtype(COLUMN)是错误的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 EducationTypes 的表和一个名为 EducationType 的实体,我重命名了一个实体属性,现在我经常得到参数@objname是不明确的或声明的@objtype(COLUMN)错误。如何解决这个问题?

I've a table named EducationTypes and an Entity named EducationType, I renamed one of entity properties, now I'm frequently getting Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong. How can I solve this issue?

生成的SQL脚本:

EXECUTE sp_rename @objname = N'dbo.EducationTypes.nvarchar', @newname = N'EducationTypeTitle', @objtype = N'COLUMN'


推荐答案

如果您使用的是Code First,并且具有现有的迁移脚本,并尝试覆盖更改(即重命名列)那以后被删除,那么你会得到错误输出。最简单的方法是删除迁移脚本,通过NuGet添加迁移,然后更新数据库。

If you're using Code First and have (an) existing Migration script(s) and are trying to overwrite a change (i.e. renaming a column) that has since been deleted, then you'll get that error output. Simplest way is to delete the migration script, Add-Migration via NuGet, and then update the database.

这篇关于EF CodeFirst:参数@objname是不明确的或声明的@objtype(COLUMN)是错误的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 17:01