Devart.Data.PostgreSql.Entity.EFCore can not create EFCore migration history table in custom schema

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
jamir.araujo
Posts: 5
Joined: Wed 13 Mar 2019 17:25

Devart.Data.PostgreSql.Entity.EFCore can not create EFCore migration history table in custom schema

Post by jamir.araujo » Thu 10 Oct 2019 14:06

I'm using the package Devart.Data.PostgreSql.Entity.EFCore, version 7.14.1470.0, and I'm facing an error when I try to set a custom schema to the migration history table.

Here is some code:

Code: Select all

var builder = new DbContextOptionsBuilder<ContactContext>();

builder.UsePostgreSql(
      "Data Source=localhost;User Id=postgres;Password=admin;Database=Contacts;Unicode=true",
       b => b.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "SomeSchema"));
If I try to initiate a database with the command Update-Database, the following error is thrown:

Code: Select all

Failed executing DbCommand (9ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
-- Script
CREATE SCHEMA IF NOT EXISTS "TestSchema";
CREATE TABLE "TestSchema"."__EFMigrationsHistory" ( 
  "MigrationId" varchar(150) NOT NULL,
  "ProductVersion" varchar(32) NOT NULL,
  PRIMARY KEY ("MigrationId")
)
Devart.Data.PostgreSql.PgSqlException (0x80004005): cannot insert multiple commands into a prepared statement
   at   .(Boolean , Boolean , Char , Boolean )
   at   .      (   )
   at   .()
   at Devart.Data.PostgreSql.PgSqlCommand.InternalPrepare(Boolean implicitPrepare, Int32 startRecord, Int32 maxRecords)
   at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
   at Devart.Common.DbCommandBase.ExecuteNonQuery()
   at   .ExecuteNonQuery()
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
cannot insert multiple commands into a prepared statement

Shalex
Site Admin
Posts: 8829
Joined: Thu 14 Aug 2008 12:44

Re: Devart.Data.PostgreSql.Entity.EFCore can not create EFCore migration history table in custom schema

Post by Shalex » Fri 11 Oct 2019 17:34

Please add "UnpreparedExecute=true;" to your connection string. Refer to https://www.devart.com/dotconnect/postg ... tring.html.

jamir.araujo
Posts: 5
Joined: Wed 13 Mar 2019 17:25

Re: Devart.Data.PostgreSql.Entity.EFCore can not create EFCore migration history table in custom schema

Post by jamir.araujo » Mon 14 Oct 2019 20:24

I've added the "UnpreparedExecute=false" parameter to my connection string with no efect. The error is still the same.

The only thing that works is adding "Protocol=ver20" to the connection string.

Post Reply