每个表中的列名必须是唯一的.表“dbo.Foos"中的列名“StripeRecipientId"被指定了多次 [英] Column names in each table must be unique. Column name 'StripeRecipientId' in table 'dbo.Foos' is specified more than once

查看:19
本文介绍了每个表中的列名必须是唯一的.表“dbo.Foos"中的列名“StripeRecipientId"被指定了多次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 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 commandlet 不久前的先前运行创建.

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.

我正在使用实体框架 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.

这篇关于每个表中的列名必须是唯一的.表“dbo.Foos"中的列名“StripeRecipientId"被指定了多次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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