且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

更新数据库:“在建立到SQL Server的连接时发生了与网络相关或特定于实例的错误".

更新时间:2023-02-03 07:53:32

我终于找到了.我的解决方案中有一个网站项目和我的API.问题在于该网站被设置为启动项目.因此,该实体框架在网站的web.config中而不是在api的web.config中搜索连接字符串.将启动项目更改为我的API可以解决此问题.

I finally found out. I have a website project and my API in my solution. The problem was that the website was set as startup project. So that entity framework searched the connection string in the website's web.config and not in the api's web.config. Changing the startup project to my API solved the problem.

如果要将网站项目作为启动项目.只需将连接字符串复制到Websides web.config.

If you want to have the website project as startup project. Just copy the connection string into the websides web.config.

尽管如此,感谢大家的帮助.

Nevertheless thanks for everyones help.