英文:
Entity Framework can't connect to my database
问题
我试图连接到我在SSMS中创建的空SQL Server数据库,用于我正在开发的Blazor项目。作为这个过程的一部分,我试图创建一个新表,但是当我尝试将其迁移到我的数据库时,似乎无法使其工作。
当我尝试在控制台中更新数据库时,update-database
命令似乎工作正常,但实际上没有任何数据被推送到我的数据库。如果我从我的 .json
文件中删除连接字符串并将其直接传递给 options.UseSqlServer()
,那么在尝试更新数据库时会引发以下错误:
在建立到 SQL Server 的连接时发生与网络相关或特定于实例的错误。未找到服务器或无法访问服务器。请验证实例名称是否正确,并且 SQL Server 配置为允许远程连接。(提供程序: SNI_PN11,错误: 26 - 找不到服务器/指定的实例)
远程连接已启用,连接字符串只是直接从我的SQL Server资源管理器复制的。我唯一能想到的可能是连接字符串属性与我的设置不兼容,或者其他什么原因?我的连接字符串如下:
Data Source = Desktop-UGF6TEE\\MyDataSource; Integrated Security = True; Connect Timeout = 30; Encrypt = False; Trust Server Certificate = False; Application Intent = ReadWrite; Multi Subnet Failover = False
英文:
I'm trying to connect to an empty SQL Server database I've created in SSMS for a Blazor project I'm working on. As part of this, I'm trying to create a new table, but when I try to migrate it to my database, I can't seem to get it to work.
When I attempt to update the database in the console, the update-database
command seems to work fine, but nothing is actually pushed to my database. If I take the connection string out of my .json
file and pass it directly to options.UseSqlServer()
, this error is raised when trying to update the database:
> A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SNI_PN11, error: 26 - Error Locating Server/Instance Specified)
Remote connections are enabled, and the connection string is just directly copied from my SQL Server explorer. Only thing I can think of is maybe an incompatibility with my connection string properties or something?
My connection string is:
Data Source = Desktop-UGF6TEE\\MyDataSource; Integrated Security = True; Connect Timeout = 30; Encrypt = False; Trust Server Certificate = False; Application Intent = ReadWrite; Multi Subnet Failover = False
答案1
得分: 1
尝试使用集成安全性=SSPI;
我认为问题出在这里。
英文:
try Integrated Security=SSPI;
I think the issue comes here.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论