EduardoPires / EquinoxProject

Full ASP.NET Core 6 application with DDD, CQRS and Event Sourcing concepts

Home Page:http://equinoxproject.azurewebsites.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to connect to SQL Server.

ascariz opened this issue · comments

When executing and registering a user it gives me this error:

I have in my SQL Server: PORTATIL \ SQLPORTATIL -> Equinox -> Created the Database with the GenerateDataBase.sql

I have in the configuration files like this "DefaultConnection": "Server = PORTATIL \ SQLPORTATIL; Database = Equinox; User Id = sa; password = CccpB003; Trusted_Connection = False; MultipleActiveResultSets = true;" and the error it gives me are:

A database operation failed while processing the request.
SqlException: Cannot open database "Equinox" requested by the login. The login failed. Login failed for user 'PORTATIL \ rodrigo'.
Use migrations to create the database for NetDevPackAppDbContext
In Visual Studio, use the Package Manager Console to scaffold a new migration and apply it to the database:

PM> Add-Migration [migration name]
PM> Update-Database
Alternatively, you can scaffold a new migration and apply it from a command prompt at your project directory:

dotnet ef migrations add [migration name]
dotnet ef database update

Thank you

dotnet ef migrations add Initial --context EquinoxContext --project Equinox.Infra.Data/Equinox.Infra.Data.csproj --startup-project Equinox.UI.Web/Equinox.UI.Web.csproj
dotnet ef migrations add Initial --context EventStoreSqlContext --project Equinox.Infra.Data/Equinox.Infra.Data.csproj --startup-project Equinox.UI.Web/Equinox.UI.Web.csproj
dotnet ef migrations add Initial --context NetDevPackAppDbContext --project Equinox.Infra.CrossCutting.Identity/Equinox.Infra.CrossCutting.Identity.csproj --startup-project Equinox.UI.Web/Equinox.UI.Web.csproj

dotnet ef database update --context EquinoxContext --project Equinox.Infra.Data/Equinox.Infra.Data.csproj --startup-project Equinox.UI.Web/Equinox.UI.Web.csproj
dotnet ef database update --context EventStoreSqlContext --project Equinox.Infra.Data/Equinox.Infra.Data.csproj --startup-project Equinox.UI.Web/Equinox.UI.Web.csproj
dotnet ef database update --context NetDevPackAppDbContext --project Equinox.Infra.CrossCutting.Identity/Equinox.Infra.CrossCutting.Identity.csproj --startup-project Equinox.UI.Web/Equinox.UI.Web.csproj

The problem was that there is more than one connection to BD, changing all the appsettings.json
with that everything was solved.
Thank you