EF Core 8 - RelationalConnectionDependency 不包含“With”的定义

问题描述 投票:0回答:1

我正在将项目从

.NET Core 2.1
升级到
.NET 8
,作为其中的一部分,我还需要将
Entity Framework Core
升级到 8.0。

在其中一个代码行中,使用了“With”方法,但该方法不可在 EF Core 8.0 中使用,因此,我收到错误。

那么,有什么替代方法可以使用吗?

enter image description here

我试图从 EF Core 文档中找到替代方法,但找不到。

使用语句:

使用 System.Data.Common;

使用System.Data.SqlClient;

使用 Microsoft.EntityFrameworkCore;

使用 Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal;

使用 Microsoft.EntityFrameworkCore.Storage;

发生错误的代码:

    var contextOptions = new DbContextOptionsBuilder()
    .UseSqlServerForAzure(
        connectionStringBuilder.ConnectionString,
        b => b.CommandTimeout(CommandTimeout ?? DefaultMasterConnectionCommandTimeout))
    .Options;
return new AzureSqlMsiRelationalConnection(Dependencies.With(contextOptions));
entity-framework-core
1个回答
0
投票

您应该使用 与表达式

new AzureSqlMsiRelationalConnection(Dependencies with { ContextOptions = contextOptions });
© www.soinside.com 2019 - 2024. All rights reserved.