1

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

Tarta
  • 1,729
  • 1
  • 29
  • 63
  • You can't connect to a database that doesn't exist. If you know it doesn't exist, don't try connecting to it. – Thom A Feb 16 '20 at 10:08
  • 1
    @Larnu "Created database..." the EnsureDatabase creates it – Tarta Feb 16 '20 at 10:25
  • Experiencing same. I opened up a Github issue: https://github.com/DbUp/DbUp/issues/489 – derekbaker783 Feb 22 '20 at 19:54
  • 1
    @derekbaker783 that's great man! In the meantime I tell you who I resolved it: downgrade to previous version and the problem is not there anymore – Tarta Feb 22 '20 at 23:09

2 Answers2

0

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)

Tarta
  • 1,729
  • 1
  • 29
  • 63
-1

We also need to set authentication to trust in C:\Program Files\PostgreSQL\11\data\pg_hba.conf - view details

enter image description here

Minh Nguyen Van
  • 109
  • 1
  • 2