C
C#14mo ago
dan.

❔ EF successfully updated database, but unable to connect to sql server when getting data.

Hey guys, getting back into .net after a while. sql server is currently on docker and I am able to connect to the db when running my migration. However, trying to get data through the same context used when running the migration I am unable to connect to the sql server. Any tips? Currently loosely following a tutorial which doesn't use docker for his DB. Using .net 7 Full connection string: "Server=localhost;Database=superherodb;User=SA;Password=M1P4ssw0rd!@#;TrustServerCertificate=true;integrated security=false"
4 Replies
Tvde1
Tvde114mo ago
If you're sending the request to a running docker container, are you sure the docker image is up to date? Also, can one docker container reach the other? I think in the connection string you need to put Server=superherodatabase You can override the connection string in your docker-compose environment variables using:
environment:
ConnectionStrings__DefaultConnection: "Server=superherodatabase,Password=...."
environment:
ConnectionStrings__DefaultConnection: "Server=superherodatabase,Password=...."
(note two underscores)
Unknown User
Unknown User14mo ago
Message Not Public
Sign In & Join Server To View
dan.
dan.14mo ago
you're right! I was completely forgetting that running the migration is calling from local to the sql server container whereas the application is from a docker container to another one catfacepalm I'll play around and keep you posted with the solution! thanks a lot
Accord
Accord14mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.