"EnsureDatabase" 第一次失败:"Database not found on server with connection string in settings"

"EnsureDatabase" fails the first time with: "Database not found on server with connection string in settings"

我正在尝试使用 DbUp 为我的数据库设置迁移脚本。 问题是每当我使用:

var connectionString = configuration.GetSection("DbSetting").Get<DbSettings>().ConnectionString;
EnsureDatabase.For.SqlDatabase(connectionString);

EnsureDatabase 失败并出现错误:

Database not found on server with connection string in settings: Cannot open database "TvMazeScraperDB" requested by the login. The login failed.

要点是 Db 尚不存在,这就是为什么我 运行 以创建它的方式 EnsureDatabase 的原因!有什么解决办法吗?提前致谢!

编辑:我注意到奇怪的是,如果我一步一步地调试,一切都会很好。但是如果我 运行 应用程序反而出现问题:

4.3.0 版本出现问题。降级到 4.0.0,它不会再发生(作为一个临时修复,直到一个稳定的)

我们还需要在C:\Program Files\PostgreSQL\data\pg_hba.conf中设置认证信任 - 查看详情