简体   繁体   中英

Database creation issue after running ASP.NET MVC project

I have a propblem related to the first run of an ASP.NET MVC application containing a database.

I was forced to install a new Windows and migrate my ASP.NET MVC project to it (previously I put it on the Github respository).

In the new installation of the system - I launched VisualStudio, logged into Github and downloaded the project from the repository. However, when I try to run, I get the error:

System.Data.SqlClient.SqlException: 'Directory lookup for the file.... / AppName.mdf "failed with the operating system error 2. CREATE DATABASE failed. Some file names listed could not be created. Check related errors. '

The application previously used a local database. This is what connection string looks like:

<add name="AppNameContext" connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=AppName;Integrated Security=SSPI; AttachDBFilename=|DataDirectory|\AppName.mdf" providerName="System.Data.SqlClient" />

Did I skip any step in configuring new visual studio and don't want to create a new database?

Your application is missing the App_Data folder. Right click on your project, select Add, then Add ASP.Net Folder and choose the App_Data folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM