1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

EF6で、クラウド上のPostgreSQLの、template1権限エラーを解決する

Posted at

問題 

EntityFramework 6.3で、ElephantSQL、Herokuの、PostgreSQLへの接続を行った時に、

System.Data.Entity.Core.ProviderIncompatibleException: The provider did not return a ProviderManifestToken string. ---> Npgsql.PostgresException: 42501: permission denied for database "template1"
のようなエラーが発生。

template1への権限が無いよ、というもの。

解決方法

ConnectionStringに、
EntityAdminDatabase=「データベース名」
を追加

参考

この解決方法に至るまでの試行錯誤

  • 2019/10/1時点では、自分の環境ではこの問題は発生していなかった。
  • 2019/11/13に、この問題を認識。
  • ローカルのPostgreSQLに接続してから、クラウドのPostgreSQLに接続すると、問題は発生しない。クラウドのElephantSQLに、最初に接続すると、問題発生、という現象。
    そのため、ローカル接続を行ってからの場合、行わなかった場合、の2パターンで、プロパティの差を調べれば解決できるのでは、と考え、調査。→ プロパティの値に差はあったが、それ以上のことは検索しても分からず。
  • template1を調査。
    template1は、CreateDatabase(?)を行うために、PostgreSQLが利用しようとしているのだろうと、思い当たる(ここまで半日)
  • データベース作成を止める方法を調査。
  • System.Data.Entity.Database.SetInitializer<TContext>(null);
    としていたので、
    SetInitializerを、様々に指定して、トライ。→ 解決せず。
  • 検索キーワードを変えて、検索。ようやく、上記のstackoverflowの記事にたどり着く。
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?