dbContext.Database.Exists() Error

dbContext.Database.Exists() Error

Postby khorvat » Fri 13 Dec 2013 09:49

Hi,

I'm evaluating dotConnect for PostgreSQL and I have switched all of my existing configuration (web.config) from SQL Server to PostgreSQL. Now when I hit the dbContext.Database.Exists() I get the following error:

Code: Select all
"Message": "An error has occurred.",
"ExceptionMessage": "Sequence contains no matching element"


My configuration is like this:

Code: Select all
<section name="Devart.Data.PostgreSql.Entity" type="Devart.Data.PostgreSql.Entity.Configuration.PgSqlEntityProviderConfigurationSection, Devart.Data.PostgreSql.Entity" />

<add name="DefaultConnection" providerName="Devart.Data.PostgreSql" connectionString="Server=localhost;Port=5432;Database=db;user=username;password=pass;" />

<DbProviderFactories>
      <remove invariant="Devart.Data.PostgreSql" />
      <add name="dotConnect for PostgreSQL" invariant="Devart.Data.PostgreSql"
       description="Devart dotConnect for PostgreSQL"
       type="Devart.Data.PostgreSql.PgSqlProviderFactory, Devart.Data.PostgreSql" />

    </DbProviderFactories>

<defaultConnectionFactory type="MyNameSpace.PostgresConnectionFactory, MyAssembly">
    </defaultConnectionFactory>

<providers>
      <provider invariantName="Devart.Data.PostgreSql" type="Devart.Data.PostgreSql.Entity.PgSqlEntityProviderServices,
Devart.Data.PostgreSql.Entity" />
    </providers>


I have copied PostgresConnectionFactory implementation from your site and when I try to debug the code I get the connection which I can properly open and close. Also I can open and close the connection to server from VS 2013.

I'm using the .NET 4.5.1, EF 6.x, VS 2013 and PostgreSQL Server 9.3.2 and I'm using dotConnect version 7.2.55.

Any ideas ?

Thanks
khorvat
 
Posts: 6
Joined: Fri 13 Dec 2013 09:35

Re: dbContext.Database.Exists() Error

Postby khorvat » Fri 13 Dec 2013 14:40

Ok, here is a bit longer stack trace

at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
at System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration.Configure(EdmProperty column, EntityType table, DbProviderManifest providerManifest, Boolean allowOverride, Boolean fillFromExistingConfiguration)
at System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration.<>c__DisplayClass1.<Configure>b__0(Tuple`2 pm)
at System.Data.Entity.Utilities.IEnumerableExtensions.Each[T](IEnumerable`1 ts, Action`1 action)
at System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.BinaryPropertyConfiguration.Configure(IEnumerable`1 propertyMappings, DbProviderManifest providerManifest, Boolean allowOverride, Boolean fillFromExistingConfiguration)
at System.Data.Entity.ModelConfiguration.Configuration.Types.StructuralTypeConfiguration.ConfigurePropertyMappings(IList`1 propertyMappings, DbProviderManifest providerManifest, Boolean allowOverride)
at System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.ConfigurePropertyMappings(DbDatabaseMapping databaseMapping, EntityType entityType, DbProviderManifest providerManifest, Boolean allowOverride)
at System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.Configure(EntityType entityType, DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest)
at System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.ConfigureEntityTypes(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest)
at System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.Configure(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest)
at System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo)
at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.InternalContext.CreateObjectContextForDdlOps()


Regards
khorvat
 
Posts: 6
Joined: Fri 13 Dec 2013 09:35

Re: dbContext.Database.Exists() Error

Postby khorvat » Mon 16 Dec 2013 10:51

I have tried Code First approach with totally new dbContext and I get the following error:

Code: Select all
{
    "Message": "An error has occurred.",
    "ExceptionMessage": "An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.",
    "ExceptionType": "System.Data.Entity.Core.ProviderIncompatibleException",
    "StackTrace": "   at System.Web.Http.ApiController.<InvokeActionWithExceptionFilters>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__0.MoveNext()",
    "InnerException": {
        "Message": "An error has occurred.",
        "ExceptionMessage": "The provider did not return a ProviderManifestToken string.",
        "ExceptionType": "System.Data.Entity.Core.ProviderIncompatibleException",
        "StackTrace": "   at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)\r\n   at System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection)",
        "InnerException": {
            "Message": "An error has occurred.",
            "ExceptionMessage": "database \"MyDatabase\" does not exist",
            "ExceptionType": "Devart.Data.PostgreSql.PgSqlException",
            "StackTrace": "   at Devart.Data.PostgreSql.v.y()\r\n   at Devart.Data.PostgreSql.v.b()\r\n   at Devart.Common.DbConnectionFactory.b(DbConnectionBase A_0)\r\n   at Devart.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)\r\n   at Devart.Common.DbConnectionBase.Open()\r\n   at Devart.Data.PostgreSql.PgSqlConnection.Open()\r\n   at Devart.Common.Entity.e1.a(DbConnection A_0)\r\n   at Devart.Data.PostgreSql.Entity.PgSqlEntityProviderServices.GetDbProviderManifestToken(DbConnection baseConnection)\r\n   at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)"
        }
    }
}


I'm trying to test Database Create functionality and it seems to me that provider is trying to open a connection to the database that we should create, why ?

Regards
khorvat
 
Posts: 6
Joined: Fri 13 Dec 2013 09:35

Re: dbContext.Database.Exists() Error

Postby MariiaI » Mon 16 Dec 2013 11:22

We have contacted you by e-mail.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: dbContext.Database.Exists() Error

Postby nastradamus » Mon 02 Jun 2014 09:52

The solution of this Problem is probably the solution of my Problem. I have started a thread for it here: http://forums.devart.com/viewtopic.php?f=3&t=29660

Please, can someowne share the solution?
nastradamus
 
Posts: 5
Joined: Wed 14 May 2014 14:11

Re: dbContext.Database.Exists() Error

Postby MariiaI » Mon 02 Jun 2014 10:31

nastradamus wrote:The solution of this Problem is probably the solution of my Problem. I have started a thread for it here: http://forums.devart.com/viewtopic.php?f=3&t=29660

Please, can someowne share the solution?

We have contacted you by e-mail.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17


Return to dotConnect for PostgreSQL