Skip to content

GetDiscoveredScripts throws a NullReferenceException when using WithScriptsAndCodeEmbeddedInAssembly #6

@blankensteiner

Description

@blankensteiner

Hi

Let's start with the code (using the latest version of DbUp in a .NET Core 3.1 application).

var upgradeEngine = DeployChanges.To
                    .SqlDatabase("snip")
                    .LogToConsole()
                    .WithScriptsAndCodeEmbeddedInAssembly(Assembly.GetExecutingAssembly())
                    .Build();

Console.WriteLine("Discovered scripts:");
foreach (var script in upgradeEngine.GetDiscoveredScripts())
    Console.WriteLine("\t" + script.Name);

Calling GetDiscoveredScripts or GetExecutedButNotDiscoveredScripts will both call GetDiscoveredScriptsAsEnumerable, which in turn will call EmbeddedScriptAndCodeProvider.GetScripts which will then call ScriptsFromScriptClasses. This is a problem since it will call DatebaseConnectionManager.ExecuteCommandsWithManagedConnection and here the 'transactionStrategy' field is null, because OperationStarting has never been called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Bugs

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions