【问题标题】:Web.Config file missing from ASP.NET Core 6 MVCASP.NET Core 6 MVC 中缺少 Web.Config 文件
【发布时间】:2023-01-30 18:53:26
【问题描述】:

web.config 文件丢失了,我不知道在哪里放置我的连接字符串。

这是我的DbContext代码:

namespace Patient_Enrollment.Repo
{
    public partial class Contxt : DbContext
    {
        public Contxt() : base("name= EnrollmentEntity")
        {
        }
    }
}

这是我的家庭控制器,我在其中使用Contxt

 public static Contxt GetContxt()
 {
     return new Contxt();
 }

【问题讨论】:

  • 失踪?是不是不小心删了你能从你的实时/开发服务器中提取一个副本并将其添加回项目吗?如果没有,您可以右键单击该项目,添加 > Web 配置文件。然后在 <configuration> 中添加 <connectionStrings> 部分
  • 这些天 ASP.NET Core 应用程序通常使用 appSettings.json - web.config 或多或少已被弃用
  • @KevinM 习惯了 asp.net core 5,现在我试图在 asp.net 6.0 上创建一个 web 应用程序,它没有 web.config 文件,当我自己添加它时,它给我一个错误,它找不到连接字符串与“EnrollmentEntity”[(名称= EnrollmentEntity)]

标签: database-connection connection-string asp.net-core-6.0


【解决方案1】:

enter image description here

在 Visual Studio 2017 中,在解决方案资源管理器中的项目中单击鼠标右键 -> 添加 -> 新建项 -> 搜索“config” -> 添加 Web 配置文件。这将使用默认内容在您的项目中添加 web.config。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-10-08
    • 1970-01-01
    • 2011-11-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-13
    • 2015-09-22
    • 1970-01-01
    相关资源
    最近更新 更多