我正在尝试在 Visual Studio 2022 中使用 .NET 6 将我的 DbContext 注册为我的 program.cs 中的服务,但出现错误。获取连接字符串

互联网 行业动态 更新时间:2024-06-13 00:19:07

Cla*_*zye 5

所以我发现我不得不说builder.Congiguration,而不仅仅是这样的配置:

builder.Services.AddDbContext<AppDbContext>(options =>
{
                         //the change ours here.
                         //builder.cofiguration and not just configuration
    options.UseSqlServer(builder.Configuration.GetConnectionString("Default"));
});

您的代码中有“配置”变量,那么您为什么希望能够使用它?您尝试使用的 `Configuration` 是 `System.Configuration` 命名空间。如果您发布了实际的编译错误,这将很清楚。 (2认同)

更多推荐

字符串,出现错误,Studio,Visual,NET

本文发布于:2023-04-20 21:03:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/hyzx/36780ed220b855e733de79f13b841888.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   出现错误   Studio   Visual   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!