I am using VS2010 Beta 2 to create an IIS hosted WCF service. I added a SQL Server database file to use as a simple data store and then generated some Linq to SQL classes to interact with it.
The problem I have happens when Linq to SQL tries to connect to the database. I get the following error below:
CREATE DATABASE permission denied in database 'master'. An attempt to attach an auto-named database for file c:\Source\SampleApp\App_Data\GameData.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
To get around a previous problem I have already changed the web.config to not use an user instance:
<add name="GameDataConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\GameData.mdf;Integrated Security=True;User Instance=False"
providerName="System.Data.SqlClient" />
My first reaction is that the application pool's user account (NETWORK SERVICE) is unable to open the file so I have granted full control to the database file and log file but this did not help.
Interestingly if I change the application pool to run under local system everything works correctly. Is there something else I have to grant NETWORK SERVICE access to?