This is my postgresql migration code. There is no problem when i running project in visual studio.
services.AddDbContext<myDbContext>(options => options.UseNpgsql("User ID=myuser;Password=123;Host=localhost;Port=5432;Database=testDb;Pooling=true;"));
using var scope = services.BuildServiceProvider().CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<myDbContext>();
dbContext.Database.Migrate();
But when ı run in docker compose mode, i gets this error at line dbContext.Database.Migrate()
ExtendedSocketException: Cannot assign requested address [::1]:5432 This exception was originally thrown at this call stack: System.Net.Sockets.Socket.DoConnect(System.Net.EndPoint, System.Net.Internals.SocketAddress) System.Net.Sockets.Socket.Connect(System.Net.EndPoint) Npgsql.NpgsqlConnector.Connect(Npgsql.Util.NpgsqlTimeout)