【发布时间】:2017-03-09 08:18:24
【问题描述】:
我明天有一个作业要交,我正在慢慢失去理智。一些帮助将不胜感激。
我不断收到回复 -
“System.Data.SqlClient.SqlException”类型的未处理异常 发生在EntityFramework.SqlServer.dll
附加信息:执行超时已过期。在操作完成之前超时时间已过或服务器没有响应。
附加信息:在模型生成过程中检测到一个或多个验证错误:
以下是我的两个 app.configs
CONSOLE APP.CONFIG
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<startup>
<connectionStrings>
<add
name="VoteWithDEV"
connectionString="Data Source=k2mmbsouh0.database.windows.net;
Initial Catalog=VoteWithDEV;Persist Security Info=True;User ID=patrickmcmu11an;;Password=Jordan123"
providerName="System.Data.SqlClient"/>
</connectionStrings>
<appSettings>
<add key="ConnectionStringName" value="VoteWithDEV"/>
</appSettings>
</startup>
DATA APP.Config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb"/>
</parameters>
</defaultConnectionFactory>
</entityFramework>
<connectionStrings>
<add
name="VoteWithDEV"
connectionString="Data Source=k2mmbsouh0.database.windows.net;
Initial Catalog=VoteWithDEV;Persist Security Info=True;User ID=username;Password=password"
providerName="System.Data.SqlClient"/>
</connectionStrings>
<appSettings>
<add key="ConnectionStringName" value="VoteWithDEV"/>
</appSettings>
</configuration>
【问题讨论】:
-
您的计算机无法访问数据库。您的代码可能没有任何问题。服务器
k2mmbsouh0.database.windows.net的物理位置在哪里?你能通过 1433 端口上的 telnet 访问它吗? -
为了您自己的隐私,请编辑您的凭据。
-
根据服务器的 URL,我假设这是一个 Azure SQL 数据库。您是否在 Azure 中正确设置了防火墙?
标签: c# asp.net .net sql-server entity-framework