EFCore is incapable of connecting to DB despite everything else being able to
Mystifying me because
- SSMS connects fine
- Migration commands like
Add-Migration "Add_Table"
and Update-Database
work fine
can also be viewed from DB side.
I am always encountering this error from EFCore when I run the application:
Code will be in responses6 Replies
AppDbContext.cs:
Program.cs:
Ok, I think it is bc I am debugging via dockerfile. Https works
How can I update my dockerfile to allow EFCore to connect to my local machine?
If your app runs in docker, you need to use a connection string that targets the host instead of localhost. iirc that's enabled by default in docker for windows, and if you Google it you'll find the right hostname
host.docker.internal
on docker-for-windows and docker-for-mac
see top answer at https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach for a lot more detailI just used docker-compose and accessed the db by name instead
idk if copout lol
Oh, so db was a container too, even beforehand?
no, it was local