如果在远程服务器上部署站点之后,是否获得System.Data.EntityClient.EntityConnection.OpenStoreConnection?

时间:2018-07-26 05:49:36

标签: c# .net sql-server asp.net-mvc visual-studio-2010

我是C#和.NET的新手,我已经在本地计算机上开发了C#MVC3(使用Entity Framework)网站,并将该网站发布到远程服务器。

2018-07-26 10:38:10,103 [6] INFO  MySite.Controllers.homeController [(null)] - Inside homecontroller Index () 
2018-07-26 10:38:18,007 [10] INFO  MySite.Controllers.homeController [(null)] - Inside homecontroller Index () 
2018-07-26 10:38:29,742 [8] INFO  MySite.Controllers.homeController [(null)] - Inside homecontroller Login Post () 
2018-07-26 10:38:32,148 [8] ERROR MySite.Controllers.homeController [(null)] - Exception inside Login () :   at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
   at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
   at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
   at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at MySite.Controllers.homeController.Login(FormCollection form) in C:\Users\DevDesk\Documents\Visual Studio 2010\Projects\Project1\MySite\Controllers\homeController.cs:line 115
2018-07-26 10:38:32,231 [5] INFO  MySite.Controllers.homeController [(null)] - Inside homecontroller Index () 

这是我的连接字符串:

 // Local Machine Connection String

 <add name="UserProfileDBEntities" 
 connectionString="metadata=res://*/Models.UserProfileModel.csdl|res://*/Models.UserProfileModel.ssdl|res://*/Models.UserProfileModel.msl;
 provider=System.Data.SqlClient;
 provider connection string=&quot;
 Data Source=LAPTOP-H0PPTKKU;
 Initial Catalog=test_db;
 User ID=dev_user;
 Password=dev_user;
 MultipleActiveResultSets=True&quot;"
 providerName="System.Data.EntityClient" />

 // Remote Server Connection String

 <add name="UserProfileDBEntities"
 connectionString="metadata=res://*/Models.UserProfileModel.csdl|res://*/Models.UserProfileModel.ssdl|res://*/Models.UserProfileModel.msl;
 provider=System.Data.SqlClient;
 provider connection string=&quot;
 Data Source=DESKTOP-MP9NGB9;
 Initial Catalog=prod_db;
 User ID=prod_user;
 Password=prod_user;
 MultipleActiveResultSets=True&quot;" 
 providerName="System.Data.EntityClient" />

现在我遇到以下错误:

2018-07-26 10:58:32,176 [20] INFO  MySite.Controllers.homeController [(null)] - Inside homecontroller Index () 
2018-07-26 10:58:59,757 [20] INFO  MySite.Controllers.UserController [(null)] - Inside UserController list() 
2018-07-26 10:58:59,766 [23] INFO  MySite.Controllers.homeController [(null)] - Inside homecontroller Index () 
2018-07-26 10:59:08,195 [23] INFO  MySite.Controllers.homeController [(null)] - Inside homecontroller Login Post () 
2018-07-26 10:59:22,986 [23] ERROR MySite.Controllers.homeController [(null)] - Exception inside Login () :   at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
   at System.Data.EntityClient.EntityConnection.Open()
   at System.Data.Objects.ObjectContext.EnsureConnection()
   at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
   at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)

设置有什么问题还是我需要对app.config文件进行任何更改??

0 个答案:

没有答案