Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tomasz Kowalski 135 posts 445 karma points
    Jul 30, 2021 @ 10:10
    Tomasz Kowalski
    0

    How to fix IncompleteMigrationExpressionException?

    Hello everybody,

    It's Friday but feels like Monday...

    I forgot (!) to add .Do() in my custom migration and now I'm getting an IncompleteMigrationExpressionException "Cannot create a new expression: the previous expression has not run."

    It's only in dev, but I can't move on. I tried to start from the beginning by deleteing migration from umbracoKeyValue, but that didn't helped.

    Any suggestions?

    Kind regards

    Tomasz

  • iNETZO 134 posts 497 karma points c-trib
    Jan 21, 2022 @ 09:27
    iNETZO
    0

    Hi Tomasz,

    I have the same problem. Did you find a solution?

    Best regards,

    iNETZO

  • Tomasz Kowalski 135 posts 445 karma points
    Jan 24, 2022 @ 07:13
    Tomasz Kowalski
    0

    Hi iNETZO,

    The problem just disappeared one day, så I didn't think of it more.

    But it rings a bell, when you mention "dbo." prefix.

    Regards

    Tomasz

  • Tor Langlo 191 posts 554 karma points
    Feb 23, 2023 @ 20:56
    Tor Langlo
    1

    One possible reason you're getting the "Cannot create a new expression: the previous expression has not run" error is that several of the property getters in the MigrationBase class call the BeginBuild() method. They do this every time they are accessed (no caching of the value). This method will set the BuildingExpression flag to true, and it's this flag being true which leads to the exception being thrown.

    So, if you have a breakpoint in your code, and you have a watch on one of these properties, display the property in the Locals or Auto panels, or hover the mouse over the property, then the flag will be set to true, and when you try to step or continue the run, the exception will be thrown. For example, if you have the following code:

    protected override void Migrate()
    {
        Logger.LogDebug("Running {MigrationStep}", nameof(AddMyTableMigration));
        if (TableExists(TableName))
            Logger.LogDebug("The database table {DbTable} already exists, skipping", TableName);
        else
            Create.Table<MyTable>().Do();
    }
    

    and you set a breakpoint inside this method, then once there, if you hover the mouse over the Create property, then you're doomed.

Please Sign in or register to post replies

Write your reply to:

Draft