0

I am following this tutorial. I did everything according to the tutroial. However, I am getting an error when I am trying to open the database. It says "cannot open the database requested by the login". I am using visual studio 2012 express. The tutorial is using 2013. Could that be a problem? Here is my connection string.

<connectionStrings>
   <add name="SchoolContext" 
        connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=ContosoUniversity;Integrated Security=True;" 
        providerName="System.Data.SqlClient"/>
</connectionStrings>

The tutorial I am following. http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application

0

2 Answers 2

1

If you have Visual Studio 2012 installed, you most likely don't have SQL Server 2012 Express which is needed for using the (localdb)\v11.0 feature.

If you have an earlier version of SQL Server Express installed, then you should try to use this connection string instead:

<connectionStrings>
   <add name="SchoolContext" 
        connectionString="server=.\SQEXPRESS;database=ContosoUniversity;Integrated Security=SSPI;" 
        providerName="System.Data.SqlClient"/>
</connectionStrings>

and then basically EF should create your database on your local SQL Server Express instance and use it from there.

Sign up to request clarification or add additional context in comments.

Comments

0

you need to add the ASPNET/Network NT account into the list of users allowed to access the DB. ASP.NET apps use the NT Service account/ASPNET account by default on the app pool.

take a look here and scroll to the SQL Server section:

http://msdn.microsoft.com/en-us/library/ff647402.aspx

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.