我正在用WCF上一门课程,在一个特定的示例中,我托管了一个WCF服务,该服务从我的SQL EXPRESS中的本地数据库获取数据。我使用WPF客户端从该服务请求数据。
当我在IIS express上托管WCF服务时,一切正常。但是当我在本地IIS上托管WCF服务时,出现以下异常:
System.Data.Entity.Core.EntityException
HResult=0x80131501
Message=The underlying provider failed on Open.
Source=EntityFramework
StackTrace:
at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
at System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection(Boolean shouldMonitorTransactions)
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__5()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()
at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
at GeoLib.Data.ZipCodeRepository.GetByZip(String zip) in D:\My Stuff\SkyDrive\Programing\On Going Courses Code\wcf-end-to-end\4-wcf-end-to-end-m4-exercise-files\Starter\GeoLib.Data\Repositories\ZipCodeRepository.cs:line 35
Inner Exception 1:
SqlException: Cannot open database "ZipCodeData" requested by the login. The login failed.
Login failed for user 'PFS1\ARIELV$'.
我去了SQL订婚工作室,发现我的用户名PFS1 \ ARIELV在“安全”部分和“登录”部分中。 这是我的连接字符串:
<add name="main" connectionString="Data Source=.\sqlexpress;Initial Catalog=ZipCodeData;Integrated Security=true" providerName="System.Data.SqlClient" />
我试图添加一个手动用户,并使用另一个具有用户ID和密码的连接字符串,但确实有效。 我不明白为什么在IIS Express中一切正常,但是在本地IIS中却无法正常工作,有人遇到这个问题并解决了吗?
此外,有人知道例外情况中$的来源吗? 我的用户名是PFS \ ARIELV。