1

I have a problem that my asp.net mvc application somehow can't create a localdb .mdf file.

For example, I am creating a new web project in VS 2015 and debug it. When I go to register and enter some new user, the app throws an exception that the file cannot be found...

I know there are similar posts, but none of the solutions helped me.

My connection string looks like this:

<add name="DefaultConnection" 
     connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=C:\Users\User\Documents\Visual Studio 2015\Projects\Auth1\Auth1\App_Data\aspnet-Auth1-20160121104112.mdf;Initial Catalog=aspnet-Auth1-20160121104112;Integrated Security=True" 
     providerName="System.Data.SqlClient" />

I already tried changing the keyword AttachDbFilename to

|DataDirectory|\aspnet-Auth1-20160121104112.mdf

I tried playing around with the Data Source.

I tried giving permission to the the SQL Server user to the folder...

I checked that VS, SQL Server 2014 and the Windows User are all using the same user.

I mean, how can a project from scratch already have a bug?

1
  • Please could you post the exact exception you are receiving. And, does that file actually exist on the filesystem or not? Commented Jan 21, 2016 at 11:42

5 Answers 5

2

Have you tried removing this part entirely?

(the part being : AttachDbFilename=C:\Users\User\Documents\Visual Studio 2015\Projects\Auth1\Auth1\App_Data\aspnet-Auth1-20160121104112.mdf)

if that doesn't work have you installed localdb?

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

1 Comment

Wow, i really didn't have Localdb installed... I assumed by installing MS SQL Server Express, it would install LocalDB with it, but nah. Thank you a lot! I was searching for a solution for about 5-6 hours...
0

Remove all the thinigs for entity related to .mdf and add again from start point

This will be automatic add all required reference and artifacts.

Comments

0

You can try to create a database inside your project(or in your solution) from scratch. Lets see whats going to happen? If there will be error, the error message will give us a hint.

Comments

0
  1. Is this a new project?

  2. Have you build and run the project?

That database will be created by the asp.net identity when a user tries to login/register. Afterwards you'll see the mdf file in the directory you specified in the connection string.

1 Comment

yes, completely new project, only files created by VS. I have built and debugged the application (F6-F5).
0

If you are working with C:\inetpub\wwwroot and you are using IIS express, make sure that app_data folder in the project is given full access for the current logged in user.

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.