I'm having a difficult time getting localdb running under IIS in the connection strings. I am running:
- Windows 10
- SQL Server 2016 Express and LocalDb installed
I added the following to my applicationHost.config,
which I would not like to do if possible, but it changed the original error I was getting about not connecting:
<applicationPools>
<add name="myappPool"
autoStart="true" managedRuntimeVersion="v4.0">
// Added this <processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" />**
</add>
<applicationPoolDefaults managedRuntimeVersion="v4.0">
<processModel identityType="ApplicationPoolIdentity"
loadUserProfile="true" setProfileEnvironment="false" />
</applicationPoolDefaults>
</applicationPools>
The myAppPool
is running under ApplicationPoolIdentity
but changing this to another level of like LocalService
doesn't help.
I am now getting this error:
An attempt to attach an auto-named database for file C:\_sites\mySite\Databases\MyDb.ldf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Here is my connection string:
<add name="core"
connectionString="Server=(localdb)\mssqllocaldb;Integrated Security=true; AttachDbFileName=C:\\_sites\mySite\Databases\MyDb.ldf;" />
I can verify that I can connect to (localdb)\mssqllocaldb
if Management Studio. I was assuming that localdb meant I did not have to attach the db like I regularly do with sql if using the connection string above. I even added anonymous logon to the file security of the files just to see what would happen.
Any ideas?