Cannot open database "ZipCodeData" from Local IIS but in IIS express everything is working

0

I am doing a course in WCF and in a specific example I am hosting a WCF service which is getting data from a local DB in my SQL EXPRESS.I use a WPF client which requests data form the Service.

When I host the WCF service on IIS express, everything works fine. but when I am hosting the WCF service on a Local IIS , I get the following exception:

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$'.

I went to my SQL engagement studio and saw that my user name PFS1\ARIELV is in the "security" section and in the "Logins" section. This is my connection string:

<add name="main" connectionString="Data Source=.\sqlexpress;Initial Catalog=ZipCodeData;Integrated Security=true" providerName="System.Data.SqlClient" />

I tried to add a manual user and used another connection string with User ID and Password and that did work. I don't understand why everything works in IIS express but it doesn't work in Local IIS, did someone had this issue and solved it ?

Also, does anyone know from where the $ came from in the exception? my user name is PFS\ARIELV.

sql
wcf
wcf-hosting
asked on Stack Overflow Jul 16, 2018 by Ariel Volnicher • edited Jul 16, 2018 by Ariel Volnicher

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0