LinqPad 8.4.11无法连接.NET 8 SQL Server DbContext问题求助
在LinqPad 8.4.11中使用.NET 8 DLL的DbContext连接报错问题
我在LinqPad 8.4.11中添加连接时遇到错误,想要使用.NET 8 DLL中的DbContext,可选的构造函数仅为DbContextOptions(连接字符串已省略):

测试连接时出现如下错误:
测试自定义EF Core连接出错:使用了命名连接字符串,但在应用配置中未找到名称为'sqlConnection'的连接字符串。请注意,命名连接字符串仅在使用'IConfiguration'和服务提供程序的场景(如典型ASP.NET Core应用)中支持。
上下文的注入代码如下:
public static void ConfigureSqlContext(this IServiceCollection services, IConfiguration configuration) => services.AddDbContext<RepositoryContext>(opts => opts.UseSqlServer(configuration.GetConnectionString("sqlConnection")) );
且appsettings.json中已配置'sqlConnection'连接字符串。
内容的提问来源于stack exchange,提问作者Paul Speranza
相关产品推荐
相关产品推荐

