SQL Source Control: Object reference not set to an instance of an object
RomekAtomek
Posts: 1 New member
I am unable to push changes due to the following error. It appears that my Source Control is crashing on a foreign key or constraint somewhere. How can I find which key on which the comparison is crashing on?
SQL Source Control Version: 7.7.9.18623
SSMS Version: 20.2.30.0
SQL Source Control Version: 7.7.9.18623
SSMS Version: 20.2.30.0
2024-11-07 09:35:58.867 +01:00|Error|RedGate.SQLSourceControl.Engine.DatabasePolling.DatabasePolling.DatabasePollingManager|38| Exception thrown during action without poller
System.NullReferenceException: Object reference not set to an instance of an object.
at RedGate.SQLCompare.Engine.Registration.ModelFactory.Populators.ConstraintPopulator.PopulateForeignKeys(Database database, IDmvModel dmvModel, Boolean caseSensitive, ProgressTracker progressTracker)
at RedGate.SQLCompare.Engine.Registration.ModelFactory.DatabasePopulator.Populate(DBPopulationOptions popOptions)
at RedGate.SQLCompare.Engine.Registration.ModelFactory.DatabasePopulator.RegisterFromFactory(Database database, Options options, Boolean includeViewColumnDetails, DatabasePopulator databasePopulator, String databaseName)
at RedGate.SQLCompare.Engine.Registration.ModelFactory.DatabaseFromLivePopulator.RegisterFromLive(Database database, LiveConnectionInstructions connectionDetails, Options options, IDmvModelFactory dmvModelFactory, Boolean includeViewColumnDetails)
at RedGate.SQLCompare.Engine.Database.<>c__DisplayClass124_0.<Register>b__0()
at RedGate.SQLCompare.Engine.Utils.GetTimeToRun(Action action)
at RedGate.SQLCompare.Engine.Database.Register(LiveConnectionInstructions connectionDetails, Nullable`1 optionsParam, IDmvModelFactory factory)
at RedGate.SQLSourceControl.Engine.CompareEngineImpl.Compare.CompareDatabase.RegisterLive(IDatabaseConnection databaseConnection, ICompareOptions options)
at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.CompareDatabaseRegistrar.<>c__DisplayClass6_0.<Register>b__0()
at RedGate.SQLSourceControl.Engine.Utils.Task.SharedUtilsUtils.DoActionWithCancel(ICancellableOperationStatus status, ICancellable cancellable, Action action)
at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.CompareDatabaseRegistrar.Register(LiveDatabaseSource source, ICancellableOperationStatus status)
at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.SocDatabaseRegistrar.<>c__DisplayClass4_0.<Register>b__0()
at RedGate.SQLSourceControl.Engine.DatabasePolling.DatabasePolling.DatabasePollingManager.RunWithoutBackgroundPolling[T](Func`1 func)
2024-11-07 09:35:58.876 +01:00|Error|RedGate.SQLSourceControl.Engine.Utils.Task.CancellableUtils|38| An error occurred
System.NullReferenceException: Object reference not set to an instance of an object.
at RedGate.SQLCompare.Engine.Registration.ModelFactory.Populators.ConstraintPopulator.PopulateForeignKeys(Database database, IDmvModel dmvModel, Boolean caseSensitive, ProgressTracker progressTracker)
at RedGate.SQLCompare.Engine.Registration.ModelFactory.DatabasePopulator.Populate(DBPopulationOptions popOptions)
at RedGate.SQLCompare.Engine.Registration.ModelFactory.DatabasePopulator.RegisterFromFactory(Database database, Options options, Boolean includeViewColumnDetails, DatabasePopulator databasePopulator, String databaseName)
at RedGate.SQLCompare.Engine.Registration.ModelFactory.DatabaseFromLivePopulator.RegisterFromLive(Database database, LiveConnectionInstructions connectionDetails, Options options, IDmvModelFactory dmvModelFactory, Boolean includeViewColumnDetails)
at RedGate.SQLCompare.Engine.Database.<>c__DisplayClass124_0.<Register>b__0()
at RedGate.SQLCompare.Engine.Utils.GetTimeToRun(Action action)
at RedGate.SQLCompare.Engine.Database.Register(LiveConnectionInstructions connectionDetails, Nullable`1 optionsParam, IDmvModelFactory factory)
at RedGate.SQLSourceControl.Engine.CompareEngineImpl.Compare.CompareDatabase.RegisterLive(IDatabaseConnection databaseConnection, ICompareOptions options)
at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.CompareDatabaseRegistrar.<>c__DisplayClass6_0.<Register>b__0()
at RedGate.SQLSourceControl.Engine.Utils.Task.SharedUtilsUtils.DoActionWithCancel(ICancellableOperationStatus status, ICancellable cancellable, Action action)
at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.CompareDatabaseRegistrar.Register(LiveDatabaseSource source, ICancellableOperationStatus status)
at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.SocDatabaseRegistrar.<>c__DisplayClass4_0.<Register>b__0()
at RedGate.SQLSourceControl.Engine.DatabasePolling.DatabasePolling.DatabasePollingManager.RunWithoutBackgroundPolling[T](Func`1 func)
at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.SocDatabaseRegistrar.Register(LiveDatabaseSource databaseSource, ICancellableOperationStatus status)
at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.TwoWorkspaceRegistrar.<>c__DisplayClass14_0.<GetRegisterWorkspacesActions>b__1(ICancellableOperationStatus s)
at RedGate.SQLSourceControl.Engine.Utils.Task.NamedOperation.Operation(ICancellableOperationStatus cancellableOperation)
at RedGate.SQLSourceControl.Engine.Utils.Task.CancellableUtils.<>c__DisplayClass3_0.<StartTask>b__0()
2024-11-07 09:35:58.883 +01:00|Error|RedGate.SQLSourceControl.Engine.Utils.ErrorReporting.IBackgroundErrorReporter|41| Reporting error originally thrown
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at RedGate.SQLSourceControl.Engine.Utils.ErrorReporting.ErrorReporterBase.Do(Action toDo, Predicate`1 isFatalPredicate, Boolean rethrow)
at RedGate.SQLSourceControl.CommonUI.ErrorHandling.BackgroundErrorReporter.DoWithObviousExceptionsNoRethrow(Action action)
at RedGate.SQLSourceControl.Ssms.Common.SsmsBackgroundErrorReporter`1.DoWithObviousExceptionsNoRethrow(Action action)
at RedGate.SQLSourceControl.Engine.Diff.BoundDatabase.<>c__DisplayClass40_0.<NotifyInteractedWith>b__0(Object _)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
System.NullReferenceException: Object reference not set to an instance of an object.
at RedGate.SQLCompare.Engine.Registration.ModelFactory.Populators.ConstraintPopulator.PopulateForeignKeys(Database database, IDmvModel dmvModel, Boolean caseSensitive, ProgressTracker progressTracker)
at RedGate.SQLCompare.Engine.Registration.ModelFactory.DatabasePopulator.Populate(DBPopulationOptions popOptions)
at RedGate.SQLCompare.Engine.Registration.ModelFactory.DatabasePopulator.RegisterFromFactory(Database database, Options options, Boolean includeViewColumnDetails, DatabasePopulator databasePopulator, String databaseName)
at RedGate.SQLCompare.Engine.Registration.ModelFactory.DatabaseFromLivePopulator.RegisterFromLive(Database database, LiveConnectionInstructions connectionDetails, Options options, IDmvModelFactory dmvModelFactory, Boolean includeViewColumnDetails)
at RedGate.SQLCompare.Engine.Database.<>c__DisplayClass124_0.<Register>b__0()
at RedGate.SQLCompare.Engine.Utils.GetTimeToRun(Action action)
at RedGate.SQLCompare.Engine.Database.Register(LiveConnectionInstructions connectionDetails, Nullable`1 optionsParam, IDmvModelFactory factory)
at RedGate.SQLSourceControl.Engine.CompareEngineImpl.Compare.CompareDatabase.RegisterLive(IDatabaseConnection databaseConnection, ICompareOptions options)
at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.CompareDatabaseRegistrar.<>c__DisplayClass6_0.<Register>b__0()
at RedGate.SQLSourceControl.Engine.Utils.Task.SharedUtilsUtils.DoActionWithCancel(ICancellableOperationStatus status, ICancellable cancellable, Action action)
at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.CompareDatabaseRegistrar.Register(LiveDatabaseSource source, ICancellableOperationStatus status)
at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.SocDatabaseRegistrar.<>c__DisplayClass4_0.<Register>b__0()
at RedGate.SQLSourceControl.Engine.DatabasePolling.DatabasePolling.DatabasePollingManager.RunWithoutBackgroundPolling[T](Func`1 func)
at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.SocDatabaseRegistrar.Register(LiveDatabaseSource databaseSource, ICancellableOperationStatus status)
at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.TwoWorkspaceRegistrar.<>c__DisplayClass14_0.<GetRegisterWorkspacesActions>b__1(ICancellableOperationStatus s)
at RedGate.SQLSourceControl.Engine.Utils.Task.NamedOperation.Operation(ICancellableOperationStatus cancellableOperation)
at RedGate.SQLSourceControl.Engine.Utils.Task.CancellableUtils.<>c__DisplayClass3_0.<StartTask>b__0()
at RedGate.SQLSourceControl.Engine.Utils.Task.CancellableUtils.ExceptionHandler.ThrowIfErrored()
at RedGate.SQLSourceControl.Engine.Utils.Task.CancellableUtils.DoInParallel(ICancellableOperationStatus status, INamedOperation[] namedActions)
at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.TwoWorkspaceRegistrar.RegisterWorkspaces(IWorkspaces workspaces, ICompareScriptDatabaseInformation scriptDatabaseInformation)
at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.ThreeWayDiffSession.RegisterWorkspaces(IWorkspaces workspaces, SourceControlRevision transientRevision)
at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.ThreeWayDiffSession.BuildCommon()
at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.DiffBuilder.GetChangeSetResolvingNoOps[T](String source, IBoundDatabase boundDatabase, IChangeSetFactory`1 changeSetFactory, ICancellableOperationStatus status, SourceControlOperation sourceControlOperation)
at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.DiffBuilder.BuildToCommitChangeSet(IBoundDatabase boundDatabase, ICancellableOperationStatus status)
at RedGate.SQLSourceControl.Engine.Diff.BoundDatabase.<GetCancellableCommitableChanges>b__24_0(ICancellableOperationStatus status)
at RedGate.SQLSourceControl.Engine.Utils.Task.MutexedCancellableOperation`1.<>c__DisplayClass7_0.<Invoke>b__0()
at RedGate.SQLSourceControl.Engine.Utils.Task.CancellableOperationBase.PerformAction(Action action)
at RedGate.SQLSourceControl.Engine.Utils.Task.CancellableOperationBase.InvokeWithTracker(Action action)
at RedGate.SQLSourceControl.Engine.Utils.Task.MutexedCancellableOperation`1.Invoke()
at RedGate.SQLSourceControl.Engine.Diff.BoundDatabase.RunCommitableChangesOperationThenCleanUp(ICancellableOperation`1 changes)
at RedGate.SQLSourceControl.Engine.Diff.BoundDatabase.<>c__DisplayClass40_0.<NotifyInteractedWith>b__1()
at RedGate.SQLSourceControl.Engine.Utils.ErrorReporting.ErrorReporterBase.Do(Action toDo, Predicate`1 isFatalPredicate, Boolean rethrow)
Tagged:
Answers
If you have SQL Compare installed, you can do a comparison using your live database and the scripts' folder that is your local repository. This may then give you an insight into the object causing trouble.
If that doesn't help, we may need a copy of the database to troubleshoot
Kind regards
Dan Calver | Redgate Software
Have you visited our Help Center?