SQL Database error
sayob opened this issue · 4 comments
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.
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.
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
I encountered similar issues and have a pull request to correct them:
- 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.
- 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).
- 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.