PostgreSQL database doesn’t exist after create

I’m using very simple code to create database and use it:

using (var connection = new NpgsqlConnection(configConnectionString))     {
   var command = string.Format(@"CREATE DATABASE {0} ENCODING = 'UTF8'", databaseName);
using (var sqlCommand = connection.CreateCommand())     {
   sqlCommand.CommandText = command;

I see DB created in pgAdmin, but when I try to connect to it, I’m getting and error:

Npgsql.NpgsqlExceptionFATAL: 3D000: database “TestDb_7b2366d1366140e488bfb98b77d54cd2” does not exist

Should I put any specific permissions in order to connect to just created DB?

Source: .net

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.