You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's start with the code (using the latest version of DbUp in a .NET Core 3.1 application).
varupgradeEngine= 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.
The text was updated successfully, but these errors were encountered:
It's possible to work around this issue by triggering initialisation of the 'transactionStrategy' field.
var upgradeConfig = DeployChanges.To
.SqlDatabase("snip")
.LogToConsole()
.WithScriptsAndCodeEmbeddedInAssembly(Assembly.GetExecutingAssembly())
.BuildConfiguration();
var upgradeEngine = new UpgradeEngine(upgradeConfig);
// This ultimately ensures 'transactionStrategy' is no longer null.
using var disposableOperation = upgradeConfig .ConnectionManager.OperationStarting(
new DbUp.Engine.Output.NoOpUpgradeLog(),
new List<SqlScript>());
Console.WriteLine("Discovered scripts:");
foreach (var script in upgradeEngine.GetDiscoveredScripts())
Console.WriteLine("\t" + script.Name);
Hi
Let's start with the code (using the latest version of DbUp in a .NET Core 3.1 application).
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.
The text was updated successfully, but these errors were encountered: