I am getting this issue in .Net 5 and .Net Core 3.1, but not .Net Framework 4.7.2.
Running a simple test program:
var connectionString = @"Data Source=:memory:";
var result = DeployChanges.To
.SQLiteDatabase(connectionString)
.WithScriptsEmbeddedInAssembly(Assembly.GetEntryAssembly())
.LogToConsole()
.LogScriptOutput()
.Build()
.PerformUpgrade();
And using just this SQL script:
create table test (
contact_id INTEGER PRIMARY KEY
);
Produces this output:
Beginning database upgrade
Checking whether journal table exists..
Journal table does not exist
Executing Database Server script 'dbup.SchemaMigrations.0000001_Initial.sql'
Checking whether journal table exists..
Creating the [SchemaVersions] table
The [SchemaVersions] table has been created
Exception has occured in script: 'dbup.SchemaMigrations.0000001_Initial.sql'
System.ArgumentNullException: SafeHandle cannot be null. (Parameter 'pHandle')
at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success)
at Microsoft.Data.Sqlite.Interop.NativeMethods.Sqlite3_sqlite3.sqlite3_column_count(Sqlite3StmtHandle stmt)
at Microsoft.Data.Sqlite.Interop.NativeMethods.Sqlite3_sqlite3.column_count(Sqlite3StmtHandle stmt)
at Microsoft.Data.Sqlite.Interop.NativeMethods.sqlite3_column_count(Sqlite3StmtHandle stmt)
at Microsoft.Data.Sqlite.SqliteDataReader.get_FieldCount()
at DbUp.Support.ScriptExecutor.WriteReaderToLog(IDataReader reader)
at DbUp.Support.ScriptExecutor.ExecuteAndLogOutput(IDbCommand command)
at DbUp.Support.ScriptExecutor.<>c__DisplayClass18_2.<Execute>b__1()
at DbUp.SQLite.SQLiteScriptExecutor.ExecuteCommandsWithinExceptionHandler(Int32 index, SqlScript script, Action executeCommand)
at DbUp.Support.ScriptExecutor.<>c__DisplayClass18_0.<Execute>b__0(Func`1 dbCommandFactory)
at DbUp.Engine.Transactions.NoTransactionStrategy.Execute(Action`1 action)
at DbUp.Engine.Transactions.DatabaseConnectionManager.ExecuteCommandsWithManagedConnection(Action`1 action)
at DbUp.Support.ScriptExecutor.Execute(SqlScript script, IDictionary`2 variables)
Upgrade failed due to an unexpected exception:
System.ArgumentNullException: SafeHandle cannot be null. (Parameter 'pHandle')
at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success)
at Microsoft.Data.Sqlite.Interop.NativeMethods.Sqlite3_sqlite3.sqlite3_column_count(Sqlite3StmtHandle stmt)
at Microsoft.Data.Sqlite.Interop.NativeMethods.Sqlite3_sqlite3.column_count(Sqlite3StmtHandle stmt)
at Microsoft.Data.Sqlite.Interop.NativeMethods.sqlite3_column_count(Sqlite3StmtHandle stmt)
at Microsoft.Data.Sqlite.SqliteDataReader.get_FieldCount()
at DbUp.Support.ScriptExecutor.WriteReaderToLog(IDataReader reader)
at DbUp.Support.ScriptExecutor.ExecuteAndLogOutput(IDbCommand command)
at DbUp.Support.ScriptExecutor.<>c__DisplayClass18_2.<Execute>b__1()
at DbUp.SQLite.SQLiteScriptExecutor.ExecuteCommandsWithinExceptionHandler(Int32 index, SqlScript script, Action executeCommand)
at DbUp.Support.ScriptExecutor.<>c__DisplayClass18_0.<Execute>b__0(Func`1 dbCommandFactory)
at DbUp.Engine.Transactions.NoTransactionStrategy.Execute(Action`1 action)
at DbUp.Engine.Transactions.DatabaseConnectionManager.ExecuteCommandsWithManagedConnection(Action`1 action)
at DbUp.Support.ScriptExecutor.Execute(SqlScript script, IDictionary`2 variables)
at DbUp.Engine.UpgradeEngine.PerformUpgrade()
If I remove the LogScriptOutput() call the command works, so I can do that, but without it I lose my upgrade debug logging.
I'm using the latest versions of .Net 5 and 3.1 SDKs and dbup-sqlite v4.5.0 from NuGet.
I am getting this issue in .Net 5 and .Net Core 3.1, but not .Net Framework 4.7.2.
Running a simple test program:
And using just this SQL script:
Produces this output:
If I remove the
LogScriptOutput()call the command works, so I can do that, but without it I lose my upgrade debug logging.I'm using the latest versions of .Net 5 and 3.1 SDKs and
dbup-sqlitev4.5.0 from NuGet.