Question

I'm using dotConnect 7.3.115.0 with EntityFramework 6.0.2.

When I try to generate a script for my migration, I get the error "Requested value 'UpdateDatabaseOperation' was not found."

Here are the details and stack trace:

PM> Update-Database -Script -SourceMigration: $InitialDatabase -TargetMigration: Test -Verbose

Using StartUp project 'Domain.DataAccess'.
Using NuGet project 'Domain.DataAccess'.
Target database is: 'TestDatabase' (DataSource: localhost, Provider: Devart.Data.PostgreSql, Origin: Configuration).
Applying explicit migrations: [201403241857577_InitialCreate, 201403241941149_Test].
Applying explicit migration: 201403241857577_InitialCreate.
Applying explicit migration: 201403241941149_Test.

System.ArgumentException: Requested value 'UpdateDatabaseOperation' was not found.
   at System.Enum.EnumResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument)
   at System.Enum.TryParseEnum(Type enumType, String value, Boolean ignoreCase, EnumResult& parseResult)
   at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
   at Devart.Common.Entity.Migrations.a.b(MigrationOperation A_0)
   at Devart.Common.Entity.Migrations.f.a(MigrationOperation A_0)
   at Devart.Common.Entity.Migrations.f.a(IEnumerable`1 A_0)
   at Devart.Common.Entity.Migrations.c.a(IEnumerable`1 A_0, String A_1)
   at Devart.Data.PostgreSql.Entity.Migrations.PgSqlEntityMigrationSqlGenerator.Generate(IEnumerable`1 migrationOperations, String providerManifestToken)
   at System.Data.Entity.Migrations.DbMigrator.GenerateStatements(IList`1 operations, String migrationId)
   at System.Data.Entity.Migrations.Infrastructure.MigratorBase.GenerateStatements(IList`1 operations, String migrationId)
   at System.Data.Entity.Migrations.Infrastructure.MigratorScriptingDecorator.ScriptUpdate(String sourceMigration, String targetMigration)
   at System.Data.Entity.Migrations.Design.ToolingFacade.ScriptUpdateRunner.Run()
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
   at System.Data.Entity.Migrations.Design.ToolingFacade.ScriptUpdate(String sourceMigration, String targetMigration, Boolean force)
   at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
   at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Requested value 'UpdateDatabaseOperation' was not found.

Update

It seems that the issue is related to generating the idempotent scripts using -SourceMigration: $InitialDatabase

Per Microsoft:

Generating Idempotent Scripts (EF6 onwards)

Starting with EF6, if you specify –SourceMigration $InitialDatabase then the generated script will be ‘idempotent’. Idempotent scripts can upgrade a database currently at any version to the latest version (or the specified version if you use –TargetMigration). The generated script includes logic to check the __MigrationsHistory table and only apply changes that haven't been previously applied.

I only encounter this error when using dotConnect pointed at a PostgreSQL database. Everything works as expected when using a SQLServer instance.

Was it helpful?

Solution

Thank you for the report on this. We have reproduced this issue.

UPDATE

We have investigated the issue in more details and it is not related to dotConnect for PostgreSQL. The issue is related to the EF tool and the command being used in it:

Update-Database -Script -SourceMigration $InitialDatabase -TargetMigration: s -Verbose

It is necessary to use the '-Script' parameter or the '-Verbose' parameter, but not both at the same time. Please try using, for example:

Update-Database -Script

To get detailed information for each command please use:

get-help Update-Database -detailed 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top