Page 1 of 1

Can't create a database with automatic migration

Posted: Thu 02 Oct 2014 12:54
by t_suzuki
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"}

Re: Can't create a database with automatic migration

Posted: Thu 02 Oct 2014 14:16
by Shalex
Please use DeleteDatabaseBehaviour.Database instead of DeleteDatabaseBehaviour.AllSchemaObjects (documentation). Does this help?

Re: Can't create a database with automatic migration

Posted: Fri 03 Oct 2014 05:19
by t_suzuki
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.

Re: Can't create a database with automatic migration

Posted: Fri 03 Oct 2014 13:04
by Shalex
We have reproduced the issue. We will notify you when it is fixed.

Re: Can't create a database with automatic migration

Posted: Fri 10 Oct 2014 09:17
by Shalex
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/postgr ... nload.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.

Re: Can't create a database with automatic migration

Posted: Fri 10 Oct 2014 10:31
by t_suzuki
Thank you support Code-First. :D

Database has been created. I expected.