This is my first project using ASP.net and I'm struggling to get my database connection working. Right now the database for my application data is working and I can use the website to do simple CRUD operations. However, when I try to add Authorizarion and Authentication via the Web Site Administration Tool I get the following exception: Cannot open user default database. Login failed. Login failed for user 'PcName\UserName'.
I have tried solving this problem by using different connection strings, but without luck. They would just break my website functionality.
My connection string is:
<connectionStrings>
<add name="ProjectEntities"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;
database=ProjectDB;
AttachDBFilename=|DataDirectory|aspnetdb.mdf;
User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
I'm using Visual Studio 2010, with ASP.net MVC 3 and the Entity Framework.
I'm really out of options here, there is way too much information about SQL Server Express and ASP.net and I just can't find any working solution.
EDIT:
I tried several different connection strings as suggested below and found online. I now have a different error when trying to load the Web Site Administration Tool: Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.
When Googling that I found some solutions to fix that problem. One of those was to run aspnet_regsql.exe with some option. When doing that I get the following error message:
An error has occurred. Details of the exception:
A network-related or instance-specific error occurred while establishing a conne
ction to SQL Server. The server was not found or was not accessible. Verify that
the instance name is correct and that SQL Server is configured to allow remote
connections. (provider: Named Pipes Provider, error: 40 - Could not open a conne
ction to SQL Server)
Unable to connect to SQL Server database.
Somehow it seems that the SQL server is not running, or something. My knowledge about this subject is really insufficient to fix this problem.
EDIT 2:
I've done some more research and just tried to run the Web Site Administration Tool of an newly created MVC 3 Internet Application. When going to the security tab it gives me a different error: Could not load type 'MvcApplication1.MvcApplication'.
So my guess is that I'm missing some configurations in Web.config in my initial project (created as empty project), but somehow there is a new problem...