gpt4 book ai didi

entity-framework-migrations - 处理代码优先迁移中的错误

转载 作者:行者123 更新时间:2023-12-02 04:16:07 27 4
gpt4 key购买 nike

我的 Up() 中有以下内容

public override void Up()
{
try
{
Sql("drop index [IX_SalesInvoiceLine] on dbo.SalesInvoiceLines");
}
catch (Exception)
{
// ignored
}
string sql = @"CREATE UNIQUE NONCLUSTERED INDEX [IX_SalesInvoiceLine] ON [dbo].[SalesInvoiceLines] ( [SalesInvoice_Id] ASC, [seqNo] ASC) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]";
Sql(sql);
}

当我在调试器中单步执行代码时,我可以单步执行每一行。

但是,当我运行迁移时,我收到一条消息

"Cannot drop the index'dbo.SalesInvoiceLines_IXSalesInvoiceLine' , 
because it does not exist or you do not have permission"

为什么会抛出这个错误?

最佳答案

Up 过程正在向迁移提供命令以便稍后运行。因此,try catch 在这里不相关。

关于entity-framework-migrations - 处理代码优先迁移中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33664767/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com