EF 6: MoveTableOperation is not supported

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
PeterUser
Posts: 70
Joined: Mon 27 Feb 2017 07:45

EF 6: MoveTableOperation is not supported

Post by PeterUser » Wed 24 Jan 2018 07:05

Hello

I use EF 6 code first with migrations for my project. I have a migration that will not run. It breaks down with the following message:

Code: Select all

Applying explicit migration: 201801221522363_ExtendQmbaseLinks.
System.NotSupportedException: MoveTableOperation is not supported.
   at Devart.Common.Entity.Migrations.c.a(MoveTableOperation A_0)
   at Devart.Common.Entity.Migrations.c.c(MigrationOperation A_0)
   at Devart.Common.Entity.Migrations.c.a(IEnumerable`1 A_0)
   at Devart.Common.Entity.Migrations.d.a(IEnumerable`1 A_0, er A_1)
   at Devart.Data.Oracle.Entity.Migrations.OracleEntityMigrationSqlGenerator.Generate(IEnumerable`1 migrationOperations, String providerManifestToken)
...
The interesting part is, that the migration does not contain a MoveTable operation. The error also shows up, when I remove all steps from the migration, like:

Code: Select all

public override void Up()
{
    // Nothing to do  
}

public override void Down()
{
    // Nothing to do  
}
Any idea how I can fix that?

I found someone that reported restarting Visual Studio or clearing \bin and \obj folders might help. However, it does not seem to work for me.

Of course, I have an upcoming release date, so any help is appreciated :-)

Greetings
Peter

PeterUser
Posts: 70
Joined: Mon 27 Feb 2017 07:45

Re: EF 6: MoveTableOperation is not supported

Post by PeterUser » Wed 24 Jan 2018 08:06

Is there any way to find out which table the entiy framework wants to rename?

PeterUser
Posts: 70
Joined: Mon 27 Feb 2017 07:45

Re: EF 6: MoveTableOperation is not supported

Post by PeterUser » Wed 24 Jan 2018 09:43

After reading about how EF migrations work, I managed to decode the model XML from the __MigrationHistory and my current .resx file. This article got me on that track.

However, I don't see anything that would strike me as the cause of a MoveTabelOperation. To be more specific, three new elements got added to StorageModels.EntityContainer.EntitySet, but none have changed or been removed. That is what I would have expected from my changes to the context.

I use EF 6.2.0 and I just upgraded to dotConnect for Oracle 9.5.429.0. I can reproduce the issue on other machines.

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

Re: EF 6: MoveTableOperation is not supported

Post by Shalex » Wed 24 Jan 2018 10:26

PeterUser wrote:The interesting part is, that the migration does not contain a MoveTable operation. The error also shows up, when I remove all steps from the migration
Please upload a test project for reproducing to ftp://ftp.devart.com (credentials: anonymous / yourEmail).

PeterUser
Posts: 70
Joined: Mon 27 Feb 2017 07:45

Re: EF 6: MoveTableOperation is not supported

Post by PeterUser » Wed 24 Jan 2018 11:43

I uploaded my project. Please let me know if I can assist you in any way.

Peter

PeterUser
Posts: 70
Joined: Mon 27 Feb 2017 07:45

Re: EF 6: MoveTableOperation is not supported

Post by PeterUser » Wed 24 Jan 2018 12:06

I found out, what the Movetable-Operation is:

Entity Framework creates a MoveTableOpertation with

Code: Select all

Name = "ARIANE_ADMIN.__MigrationHistory"
NewSchema = "dbo"
Do you have any thoughts on this?

I will try to figure out, why it wants to do that. Stay tuned...

PeterUser
Posts: 70
Joined: Mon 27 Feb 2017 07:45

Re: EF 6: MoveTableOperation is not supported

Post by PeterUser » Wed 24 Jan 2018 12:25

I found the source of the problem:

In the migration's .resx file, I find

Code: Select all

  
<data name="DefaultSchema" xml:space="preserve">
    <value>dbo</value>
</data>
It should be "ARIANE_ADMIN", in my case and it is for all other migrations.

I will try to find out how that could happen.


BTW: A more verbose exception like ''MoveTableOperation is not supported. Can not move '__MigrationHistory' table from 'ARIANE_ADMIN' to 'dbo'." would have saved me some trouble.

Greetings
Peter

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

Re: EF 6: MoveTableOperation is not supported

Post by Shalex » Mon 29 Jan 2018 19:57

PeterUser wrote:I uploaded my project. Please let me know if I can assist you in any way.
1. Sorry, we cannot find your test project at ftp://ftp.devart.com . Please reupload it and specify the name of the project.
PeterUser wrote:BTW: A more verbose exception like ''MoveTableOperation is not supported. Can not move '__MigrationHistory' table from 'ARIANE_ADMIN' to 'dbo'." would have saved me some trouble.
2. We will investigate the possibility of improving an error text after reproducing the case with your test project.

PeterUser
Posts: 70
Joined: Mon 27 Feb 2017 07:45

Re: EF 6: MoveTableOperation is not supported

Post by PeterUser » Tue 30 Jan 2018 08:11

Hello

The problem is, that the migrations resx file contained

Code: Select all

  <data name="DefaultSchema" xml:space="preserve">
    <value>dbo</value>
  </data>
instead of

Code: Select all

  <data name="DefaultSchema" xml:space="preserve">
    <value>UT_ARIANE</value>
  </data>
How I managed to get "dbo" in there, I cannot say. I will keep you informed, if I find out.

Since the issue is easy to reproduce, I removed the file from the FTP. Sorry, I should have told you so. I am not sure if I am allowed to upload the samples to a publicly available, unsecured FTP anyway.

PeterUser
Posts: 70
Joined: Mon 27 Feb 2017 07:45

Re: EF 6: MoveTableOperation is not supported

Post by PeterUser » Tue 30 Jan 2018 10:36

The problem just happened again. This is what I did:
  1. Create a migration
    Schema is "ARIANE_ADMIN"
  2. Apply migration to database
  3. Revert migration in database
  4. Update migration using Add-Migration -Force
    Schema is "dbo"
Interesting note: I just tried to reproduce it again, but failed. This time the schema stayed "ARIANE_ADMIN", just as expected. Maybe I find some time to dig into the EF source code to see how that can happen.

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

Re: EF 6: MoveTableOperation is not supported

Post by Shalex » Thu 01 Feb 2018 13:15

The dbo schema in migration *.resx should not affect a migration, because IgnoreDboSchemaName=true; by default. Refer to http://devart.com/dotconnect/oracle/doc ... tions.html.

If the issue persists, please give us a test project for reproducing.

PeterUser
Posts: 70
Joined: Mon 27 Feb 2017 07:45

Re: EF 6: MoveTableOperation is not supported

Post by PeterUser » Thu 01 Feb 2018 14:21

Hello

I think you missed the point there: All tables for my entities are created in the correct schema. But EF trues to move __MigrationHistory to dbo, since it tries to put it into the schema specified in the .resx file.

This happenes in EntityFrameworks DbMigrator.GetDefaultSchema() in line 788:

Code: Select all

        private static string GetDefaultSchema(DbMigration migration)
        {
            DebugCheck.NotNull(migration);

            try
            {
                var defaultSchema = new ResourceManager(migration.GetType()).GetString(DefaultSchemaResourceKey);

                return !string.IsNullOrWhiteSpace(defaultSchema) ? defaultSchema : EdmModelExtensions.DefaultSchema;
            }
            catch (MissingManifestResourceException)
            {
                // Upgrade scenario, no default schema resource found
                return EdmModelExtensions.DefaultSchema;
            }
        }
The problem is easy to reproduce:
  1. Take any project with migrations
  2. Create a new migration
  3. Change DefaultSchema.Value in the migrations .resx file to "dbo"
  4. Apply migration
The question is: Why do I sometimes get a migration with dbo? And why does it happen (seemingly) at random?

Since I know what to fix, when I get a "MoveTableOperation is not supported" exception, it is not a big deal. It was just pretty hard to find the first time it happened.

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

Re: EF 6: MoveTableOperation is not supported

Post by Shalex » Tue 06 Feb 2018 19:42

PeterUser wrote:I found out, what the Movetable-Operation is:

Entity Framework creates a MoveTableOpertation with

Code: Select all

Name = "ARIANE_ADMIN.__MigrationHistory"
NewSchema = "dbo"
Do you have any thoughts on this?
We still cannot reproduce the issue.

1. Could you point out how you got details about MoveTableOpertation which fails to execute?

2. Please follow the steps:
a) open your project "Migration No statement parsed.zip" (uploaded for this thread)
b) comment this line in 201802011543162_Mig1.cs

Code: Select all

            //Sql("GRANT SELECT ON \"Parents\" TO LOCALTEST");
c) change DefaultSchema.Value in the migrations .resx file to "dbo"
d) run

Code: Select all

PM> Update-Database -StartUpProjectName Startup -ProjectName DAL -Verbose
Does this throw a "MoveTableOperation is not supported" exception?

PeterUser
Posts: 70
Joined: Mon 27 Feb 2017 07:45

Re: EF 6: MoveTableOperation is not supported

Post by PeterUser » Wed 07 Feb 2018 15:25

Well actually, what you are describing will work:

There is no __MigrationHistory table, so it will be created and somehow it is created in the LOCALTEST schema, regardless of the DefaultSchema property.

But if you add a second migration and set the DefautSchema to dbo for that migration, you might see the error. I do at least.

I uploaded an example named "MoveTable problem.zip" onto your ftp. Just run the following command:

Code: Select all

Update-Database -StartUpProjectName Startup -ProjectName DAL -Verbose
Sorry that I didn't make it clear that you already need migrations in the database to get a movetable operation.

Greetings
Peter

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

Re: EF 6: MoveTableOperation is not supported

Post by Shalex » Mon 12 Feb 2018 20:16

Thank you for the detailed description of the issue. We have reproduced the issue and are investigating it. We will notify you about the result.

Post Reply