Unable to create database in PostreSQL using Npgsql and Entity Framework code first

后端 未结 3 1149
温柔的废话
温柔的废话 2021-01-02 20:25

I am attempting to set up my application to use Entity Framework with PostgreSQL, but I have run up against a problem. I have added Npqsql via nuget, and added

3条回答
  •  暖寄归人
    2021-01-02 21:02

    Not surprisingly, since your database withoomph is not created yet, you should not able to use connection string where Database=withoomph; is mentioned.

    What you can do is to either create this database manually using createdb or psql, or change your connection string temporarily to use Database=postgres; instead.

    This should work because on all recent PostgreSQL versions database postgres is guaranteed to exist after vanilla install and should be used just for this purpose - to get initial authenticated connection to create another database and issue CREATE DATABASE withoomph; within your application.

    However, after your new database is created, you should immediately disconnect from postgres, connect to new withoomph and continue normally.

提交回复
热议问题