且构网

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

无法连接到sql server(使用EF)

更新时间:2023-02-04 08:57:23

你的连接应该像下一个例子:

< add name =SLOnlineShopEntitiesconnectionString =metadata = res://*/ShopModel.csdl | res://*/ShopModel.ssdl | res://*/ShopModel.msl; provider = System.Data.SqlClient; provider connection string =& quot; data source = 67.100.145.152; initial catalog = LCD-TAK; persist security info = True; user id = YourSqlLoginUser; password = YourSqlLoginPassword; multipleactiveresultsets = True; App = EntityFramework& quot; providerName =System.Data.EntityClient/>



您应该检查您的SQL Server,在与您的数据库关联的安全部分中确实有一个登录用户,其名称和密码与使用的SQL相同。 (您可以先尝试使用SQL身份验证和SQL登录用户登录SQL Management Studio。)
Your connection should be like in the next example:
<add name="SLOnlineShopEntities" connectionString="metadata=res://*/ShopModel.csdl|res://*/ShopModel.ssdl|res://*/ShopModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=67.100.145.152;initial catalog=LCD-TAK;persist security info=True;user id=YourSqlLoginUser;password=YourSqlLoginPassword;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

And you should check in your SQL Server, in the Security section associated with your database that you really have a "Login User" with name and password like in the used SQL. (You could try first to login in SQL Management Studio by using SQL Authentication and your SQL Login user.)