Can't create a database with automatic migration

Can't create a database with automatic migration

Postby t_suzuki » Thu 02 Oct 2014 12:54

I use the "MigrateDatabaseToLatestVersion".
In this case, it is necessary to create database in advance?

Or, Require connectionString of multiple to create database?


from the state of only postgres database:
Code: Select all
  <connectionStrings>
    <add name="MyContext"
         connectionString="User Id=postgres;Password=pass;Host=localhost;Database=sample1;Unicode=True;Character Set=UTF8;Initial Schema=public"
         providerName="Devart.Data.PostgreSql" />
  </connectionStrings>

Code: Select all
public class MyContext : DbContext
{
...

static void Main(string[] args)
{
Devart.Data.PostgreSql.Entity.Configuration.PgSqlEntityProviderConfig config
    = Devart.Data.PostgreSql.Entity.Configuration.PgSqlEntityProviderConfig.Instance;

config.Workarounds.IgnoreSchemaName = true;
config.Workarounds.IgnoreDboSchemaName = true;


Database.SetInitializer(
    new MigrateDatabaseToLatestVersion<MyContext, Migrations.Configuration>());

config.DatabaseScript.Schema.DeleteDatabaseBehaviour
    = Devart.Data.PostgreSql.Entity.Configuration.DeleteDatabaseBehaviour.AllSchemaObjects;

MyContext context = new MyContext();
if (!context.Database.Exists())
{
    context.Database.Create();  // <<--System.Data.Entity.Core.ProviderIncompatibleException
}

InnerException: {"database \"sample1\" does not exist"}
t_suzuki
 
Posts: 5
Joined: Wed 06 Apr 2011 07:50
Location: Japan

Re: Can't create a database with automatic migration

Postby Shalex » Thu 02 Oct 2014 14:16

Please use DeleteDatabaseBehaviour.Database instead of DeleteDatabaseBehaviour.AllSchemaObjects (documentation). Does this help?
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44

Re: Can't create a database with automatic migration

Postby t_suzuki » Fri 03 Oct 2014 05:19

I changed to DeleteDatabaseBehaviour.Database.
Is Another issue.

InvalidOperationException: Unexpected server type 'a'.
Code: Select all
at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
   at System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection)
   at Devart.Data.PostgreSql.Entity.ao.b(Version A_0)
   at Devart.Common.Entity.b5.d(Version A_0)
   at Devart.Common.Entity.b5.g()
   at Devart.Data.PostgreSql.Entity.PgSqlEntityProviderServices.GetDbProviderManifestToken(DbConnection connection)
   at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)</StackTrace><ExceptionString>System.InvalidOperationException: Unexpected server type 'a'.
   at Devart.Data.PostgreSql.Entity.ao.b(Version A_0)
   at Devart.Common.Entity.b5.d(Version A_0)
   at Devart.Common.Entity.b5.g()
   at Devart.Data.PostgreSql.Entity.PgSqlEntityProviderServices.GetDbProviderManifestToken(DbConnection connection)
   at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)


PostgreSQL 9.5.3 x86 Windows (Default Settings)
EF 6.1.1
dotConnect for PostgreSQL 7.3.254


I'll try to go in the program outside Create Database.

Thanks.
t_suzuki
 
Posts: 5
Joined: Wed 06 Apr 2011 07:50
Location: Japan

Re: Can't create a database with automatic migration

Postby Shalex » Fri 03 Oct 2014 13:04

We have reproduced the issue. We will notify you when it is fixed.
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44

Re: Can't create a database with automatic migration

Postby Shalex » Fri 10 Oct 2014 09:17

The bug with throwing "Unexpected server type 'a'" error when using DeleteDatabaseBehaviour.Database in the Code-First functionality is fixed in the latest (7.3.264) build of dotConnect for PostgreSQL.

It can be downloaded from http://www.devart.com/dotconnect/postgresql/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=3&t=30560.
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44

Re: Can't create a database with automatic migration

Postby t_suzuki » Fri 10 Oct 2014 10:31

Thank you support Code-First. :D

Database has been created. I expected.
t_suzuki
 
Posts: 5
Joined: Wed 06 Apr 2011 07:50
Location: Japan


Return to dotConnect for PostgreSQL