【发布时间】:2018-09-10 08:12:15
【问题描述】:
这是我的连接字符串:
Server=sql145.main-hosting.eu:3306;Database=u230450666_aspt;User=u230450666_aspt;Password=111111;
我是这样使用的:
services.AddDbContext<UsersContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DatabaseUrl")));
我无法连接到我的数据库,我收到了这个错误:
System.Data.SqlClient.SqlException (0x80131904):建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。 (提供者:SQL 网络接口,错误:25 - 连接字符串无效)
System.ComponentModel.Win32Exception (0x80004005):参数不正确
在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
于是我尝试了HeidiSQL,如下:
它成功了。
所以我必须错过UseSqlServer.. 的一些设置。
(我在关注this tutorial)
【问题讨论】:
标签: asp.net asp.net-web-api entity-framework-core asp.net-core-2.0 asp.net-core-webapi