Skip to content
This repository has been archived by the owner on Dec 10, 2022. It is now read-only.

SQL Database error #9

Open
sayob opened this issue Jun 26, 2017 · 4 comments
Open

SQL Database error #9

sayob opened this issue Jun 26, 2017 · 4 comments

Comments

@sayob
Copy link

sayob commented Jun 26, 2017

I am having an issue finding the attached db.
image

@negativeeddy
Copy link

it doesn't seem to be in the repo. I just changed the connection string to point to another default ASP.NET project's user db that I had created previously.

@thomashigginbotham
Copy link

For anyone else that has this issue, you can resolve it by creating a new Web API project with Individual User Accounts for authentication. After Visual Studio scaffolds out the code, copy the <connectionStrings> section from the root Web.config file, switch back to this repo's project, then paste over the <connectionStrings> in the Web.config file.

Run the project, and it should work fine.

@VeronicaWasson
Copy link
Owner

Try this: From the Package Manager Console,

enable-migrations
add-migration initial
update-database

This should create the LocalDB database.

Also, in the Web.config file, you may also need to change the connection string to point to Data Source=(LocalDb)\MSSQLLocalDB instead of (LocalDb)\v11.0

@kyle30312
Copy link

I encountered similar issues and have a pull request to correct them:

  1. As mentioned by @sayob, when opening the solution (I used Visual Studio Community 2019), a warning dialog reports:

The Web project 'LocalAccountsApp' requires SQL Server 2012 Express LocalDB, which is not installed on this computer.

  1. When running the app, using Register or Login throws this exception, after a 60 second timeout:

System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection 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: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.)

Changing the connection string as mentioned by @MikeWasson takes care of (1) and (2).

  1. Next, using Register or Login then throws this exception:

System.Data.SqlClient.SqlException: Directory lookup for the file "(solution-path)\LocalAccountsApp\App_Data\aspnet-LocalAccountsApp-20141010103649.mdf" failed with the operating system error 2 (The system cannot find the file specified.). CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

Creating the App_Data folder takes care of (3). Now, using Register or Login successfully creates the aspnet-LocalAccountsApp-20141010103649 database files (.mdf and _log.ldf), and the app functions normally.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants