数据库 'master' 中的 CREATE DATABASE 权限被拒绝。 EF 代码优先 asp.net Core 3.1
CREATE DATABASE permission denied in database 'master'. EF Code-first asp.net Core 3.1
我以前多次看到这个问题,但他们总是针对通过 App.config 文件添加连接字符串的旧方法。
我正在使用 asp.net Core 3.1 Web 应用程序,它使用 appsettings.json 创建连接字符串。具体如下:
"ConnectionStrings": {
"DefaultConnection": "Server=WS-NAME;Database=BookListRazor;User ID=sa;Password=****;Trusted_Connection=True;MultipleActiveResultSets=True"
},
我尝试过使用这个 SSMS 登录名,但我也尝试过创建一个不是 sa 的新登录名。这两个用户都启用了 dbcreator、public 和 sysadmin 服务器角色。
当我尝试使用 SSMS 手动创建数据库时,它运行得非常好。而当我使用相同的登录详细信息作为我的连接字符串的一部分时,我返回错误
CREATE DATABASE permission denied in database 'master'.
我尝试了很多建议的解决方案,但 none 似乎有效。如果你们有任何建议,我将不胜感激。
提前致谢!
这个User ID=sa;Password=****;Trusted_Connection=True
是错误的。您在传递用户 ID 和密码时将 Trusted_Connection 设置为 False。否则客户端程序的 Windows 标识用于连接到 SQL 服务器
来自文档:
If User ID and Password are specified and Integrated Security is set
to true, the User ID and Password will be ignored and Integrated
Security will be used.
我以前多次看到这个问题,但他们总是针对通过 App.config 文件添加连接字符串的旧方法。
我正在使用 asp.net Core 3.1 Web 应用程序,它使用 appsettings.json 创建连接字符串。具体如下:
"ConnectionStrings": {
"DefaultConnection": "Server=WS-NAME;Database=BookListRazor;User ID=sa;Password=****;Trusted_Connection=True;MultipleActiveResultSets=True"
},
我尝试过使用这个 SSMS 登录名,但我也尝试过创建一个不是 sa 的新登录名。这两个用户都启用了 dbcreator、public 和 sysadmin 服务器角色。
当我尝试使用 SSMS 手动创建数据库时,它运行得非常好。而当我使用相同的登录详细信息作为我的连接字符串的一部分时,我返回错误
CREATE DATABASE permission denied in database 'master'.
我尝试了很多建议的解决方案,但 none 似乎有效。如果你们有任何建议,我将不胜感激。
提前致谢!
这个User ID=sa;Password=****;Trusted_Connection=True
是错误的。您在传递用户 ID 和密码时将 Trusted_Connection 设置为 False。否则客户端程序的 Windows 标识用于连接到 SQL 服务器
来自文档:
If User ID and Password are specified and Integrated Security is set to true, the User ID and Password will be ignored and Integrated Security will be used.