string ConnectionString = "Server = 127.0.0.1; Port = 5432; Database = mydb; User Id = postgres; Password = mypwd;";
using (NpgsqlConnection con = new NpgsqlConnection(ConnectionString))
{
con.Open();
}
Let's say the database name is not "mydb" but "MyDb" or a database that does not exists.
The exception we get is :
error CS1705: Assembly 'Npgsql' with identity 'Npgsql, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Data.Common, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Data.Common' with identity 'System.Data.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
The exception expected is :
The database "mydb" does not exist
I hope this help.
Let's say the database name is not "mydb" but "MyDb" or a database that does not exists.
The exception we get is :
error CS1705: Assembly 'Npgsql' with identity 'Npgsql, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Data.Common, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Data.Common' with identity 'System.Data.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
The exception expected is :
The database "mydb" does not exist
I hope this help.