无法在appsetting.json文件中添加默认连接.在.net6



当我尝试在appsettings.json文件中添加默认连接时。在写了双引号后,我没有得到任何建议,而且还得到了一个错误,比如";在json文档中只允许一个顶级项目";

"ConnectionStrings": {
"DefaultConnection":"Server:.;Database=Bulky; Trusted_Connection:True;" 
}

您的appsettings.json文件应该是这样的

{
"ConnectionStrings": {
"DefaultConnection": "Data Source=localhost;Initial Catalog=xxx;Integrated Security=SSPI;Persist Security Info=True;",
"AnotherConnection": "Data Source=xxxx;Initial Catalog=xxx;Integrated Security=SSPI;Persist Security Info=True;"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

注意,如果你有几个连接,你需要用">

最新更新