每个表中的列名必须唯一.列名称' StripeRecipientId'在表&#39.dbo.Foos'中被指定多次 [英] Column names in each table must be unique. Column name 'StripeRecipientId' in table 'dbo.Foos' is specified more than once
问题描述
我有一个名为 Foo
的模型类,它具有这些属性.
I have a model class named Foo
that has, among others, these properties.
public string StripeRecipientId { get; set; }
public override bool HasProvidedBillingInformation
{
get
{
// return !string.IsNullOrEmpty(this.StripeRecipientId);
return false;
}
}
我已启用迁移,并且正在使用Code First.当我运行 update-database
命令集时,无论是否指定了 -Force
选项,都会出现此错误:
I have enabled migrations and am using Code First. When I run the update-database
commandlet, whether with -Force
option is specified or not, I get this error:
每个表中的列名必须唯一.表中的列名"StripeRecipientId"多次指定了"dbo.Foos".
我仔细检查了一下,三重检查了一下,在我的模型和表格中只有该名称的一列.此列是由前一阵子 update-database
命令集的先前运行创建的.
I double-checked and triple checked and there's only one column of that name in my model as well as in the table. This column was created already by a previous run of the update-database
commandlet just a while ago.
我很想删除我的数据库,然后应用迁移,但这意味着我必须创建大量测试数据才能测试我现在正在使用的功能.
I am tempted to delete my database and then apply the migrations, but that will mean me having to create a lot of test data just to be able to test the feature I am working on just now.
我正在使用Entity Framework v6.1.2.
I am using Entity Framework v6.1.2.
如何摆脱这个错误?
推荐答案
使用 -IgnoreChanges
标志运行 Add-Migration
命令.然后再次运行 Update-Database
.
Run the Add-Migration
command with the -IgnoreChanges
flag. Then run Update-Database
again.
-更新-
这些命令应在程序包管理器控制台中运行.在主菜单中:工具-> NuGet程序包管理器->程序包管理器控制台.
These commands should be run in the Package Manager Console. From the main menu: Tools-> NuGet Package Manager -> Package Manager Console.
这篇关于每个表中的列名必须唯一.列名称' StripeRecipientId'在表&#39.dbo.Foos'中被指定多次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!