I am new to ASP.NET and I'm trying to implement an ASP.NET Core MVC project.
I try to create database connection, but I got the error when the project tries to access to database with options:
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\MSSQLLocalDB;Database=DevShop;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}
In the result I got the error
Cannot open database “DevShop” requested by the login. The login failed. Login failed for user 'DESKTOP-4S2H73J\Valeryi'
I found solution there: Cannot open database "test" requested by the login. The login failed. Login failed for user 'xyz\ASPNET'
and changed the connection string to:
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\MSSQLLocalDB;Database=DevShop;User ID=DESKTOP-4S2H73J;pwd=top$secret"
}
}
In this case I get the error:
SqlException: A connection was successfully established with the server, but then an error occurred during the login process
Then I modified the string again:
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\MSSQLLocalDB;Database=DevShop;User ID=DESKTOP-4S2H73J;pwd=top$secret;Trusted_Connection=True"
}
}
And now I get error
SqlException: Cannot open database "DevShop" requested by the login. The login failed. Login failed for user 'DESKTOP-4S2H73J\Valeryi'.
I am totally confused...
- How to correctly create connection with SQL Server in Visual Studio?
- Can I use MySql server instead of SQL Server for ASP.NET Core MVC?