Invalid column name 'PrimaryToDoUsersId'
System.Data.SqlClient.SqlException (0x80131904): Invalid column name 'PrimaryTodoUsersID'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at Devolutions.RemoteDesktopManager.Business.DataSources.DatabaseConnectionDataSource.ExecuteNonQuery(String sql, IDbTransaction dbTransaction, IDbDataParameter parameters, Int32 commandTimeout)
at Devolutions.RemoteDesktopManager.Business.DataSources.DatabaseTodoSubDataSource.DeleteTodos(Connection connection, IDbTransaction transaction)
at Devolutions.RemoteDesktopManager.Business.DataSources.DatabaseConnectionDataSource.DeleteConnection(Connection connection)
I backtracked through the code and suspect the trigger for "create trigger dbo.tr_ToDoUsers on dbo.ToDoUsers is suspect. I see it referrering to the inserted column join on PrimaryToDoUsersId in dbo.ToDo. Dbo.ToDo does not have a column called PrimaryToDoUsersId. I think this was intended to be Id.
Regarding design of this, I'll suggest you consider modifying this behavior if possible as I see triggers used to do a lot of these deletes, and my general recommendation would be to instead look at establishing foreign key with cascade deletes instead of using triggers to cleanup. You can then create stored procedures that call the delete action in correct order and avoid even needing the cascade delete for larger databases. Triggers are a real antipattern in many cases that can cause scalability issues at times. I normally avoid them unless setting up some various server administration type events. That's my 10 cents, feel free to ping me with more if you want. My focus is SQL Server performance, so when I dug in and saw a lot of triggers for the maintenance, I thought perhaps you could design it more based on stored procs and FK. Not sure if this is feasible due to your cross platform schema design of course.