.netsql-serverdatabase-migrationdbup

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


I am trying to use DbUp to set up migration scripts for my Database. Problem is whenever I use:

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

The EnsureDatabase fails with the error:

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

Point is Db is not yet existing and that's why I am running the EnsureDatabase in such a way that it gets created! Any solution by any chance? Thanks in advance!

EDIT: weird thing I notice is that if I go step by step through debugging, everything works well. But if I run the application instead the problem appears:

enter image description here


Solution

  • Problem happens with 4.3.0 release. Downgrade to 4.0.0 and it won't happen anymore (as a temporary fix till a stable one)