我们在通过数据库解决方案中的 Azure Devops 部署数据库时遇到问题:
2022-01-26T09:10:26.6741963Z Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
2022-01-26T09:10:26.6742889Z at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentPlanGenerator.DeploymentScriptDomGenerator.UnbindTableDatamotion(SqlTable sourceTable, SqlTable targetTable, Boolean unbindPartitionScheme, HashSet`1 unboundColumns)
2022-01-26T09:10:26.6744135Z at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentPlanGenerator.DeploymentScriptDomGenerator.GenerateUnbindTableSteps(SqlTable sourceTable, SqlTable targetTable)
2022-01-26T09:10:26.6746179Z at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentPlanGenerator.DeploymentScriptDomGenerator.GenerateSteps(Int32 operation, IModelElement element)
2022-01-26T09:10:26.6747124Z at Microsoft.Data.Tools.Schema.Sql.Deployment.Analyzers.PlanMediator.BuildDependencyOrderedSteps(Int32 operation, List`1 classOrder, List`1 operationOrder, Dictionary`2 changes, Boolean preserveGraphs, Dictionary`2& relating, Dictionary`2& related)
2022-01-26T09:10:26.6747886Z at Microsoft.Data.Tools.Schema.Sql.Deployment.Analyzers.PlanMediator.BuildOperations()
2022-01-26T09:10:26.6748373Z at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentPlanGenerator.OnGeneratePlan()
2022-01-26T09:10:26.6748954Z at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentPlanGenerator.GeneratePlan(List`1 drops)
2022-01-26T09:10:26.6749433Z at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.BuildPlan()
2022-01-26T09:10:26.6749865Z at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.Controller.CreatePlan()
2022-01-26T09:10:26.6750293Z at Microsoft.SqlServer.Dac.DeployOperation.<>c__DisplayClass3.<>c__DisplayClass5.<CreatePlanInitializationOperation>b__1()
2022-01-26T09:10:26.6750692Z at Microsoft.Data.Tools.Schema.Sql.Dac.OperationLogger.Capture(Action action)
2022-01-26T09:10:26.6751115Z at Microsoft.SqlServer.Dac.DeployOperation.<>c__DisplayClass3.<CreatePlanInitializationOperation>b__0(Object operation, CancellationToken token)
2022-01-26T09:10:26.6751530Z at Microsoft.SqlServer.Dac.Operation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
2022-01-26T09:10:26.6751996Z at Microsoft.SqlServer.Dac.ReportMessageOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
2022-01-26T09:10:26.6752488Z at Microsoft.SqlServer.Dac.OperationExtension.CompositeOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
2022-01-26T09:10:26.6752950Z at Microsoft.SqlServer.Dac.OperationExtension.CompositeOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
2022-01-26T09:10:26.6753456Z at Microsoft.SqlServer.Dac.DeployOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
2022-01-26T09:10:26.6753964Z at Microsoft.SqlServer.Dac.OperationExtension.Execute(IOperation operation, DacLoggingContext loggingContext, CancellationToken cancellationToken)
2022-01-26T09:10:26.6754586Z at Microsoft.SqlServer.Dac.DacServices.InternalDeploy(IPackageSource packageSource, Boolean isDacpac, String targetDatabaseName, DacDeployOptions options, CancellationToken cancellationToken, DacLoggingContext loggingContext, Action`3 reportPlanOperation, Boolean executePlan)
2022-01-26T09:10:26.6757007Z at Microsoft.SqlServer.Dac.DacServices.Deploy(DacPackage package, String targetDatabaseName, Boolean upgradeExisting, DacDeployOptions options, Nullable`1 cancellationToken)
2022-01-26T09:10:26.6757864Z at Microsoft.Data.Tools.Schema.CommandLineTool.DacServiceUtil.<>c__DisplayClassd.<DoDeployAction>b__2(DacServices service)
2022-01-26T09:10:26.6758615Z at Microsoft.Data.Tools.Schema.CommandLineTool.DacServiceUtil.ExecuteDeployOperation(CommandLineArguments cmdlineArgs, String connectionString, String filePath, String modelFilePath, MessageWrapper messageWrapper, Boolean sourceIsPackage, Boolean targetIsPackage, Boolean authType, String tenantId, String customAuthArgs, Func`1 generateScriptFromPackage, Func`2 generateScriptFromDatabase)
2022-01-26T09:10:26.6759486Z at Microsoft.Data.Tools.Schema.CommandLineTool.DacServiceUtil.DoDeployAction(DeployArguments deployArgs, Action`1 writeError, Action`2 writeMessage, Action`1 writeWarning, CancellationToken cancellationToken, CommandLineArguments cmdlineArgs)
2022-01-26T09:10:26.6760035Z at Microsoft.Data.Tools.Schema.CommandLineTool.Program.DoDeployActions(CommandLineArguments parsedArgs)
2022-01-26T09:10:26.6760422Z at Microsoft.Data.Tools.Schema.CommandLineTool.Program.PerformAction(CommandLineArguments parsedArgs)
2022-01-26T09:10:26.6760761Z at Microsoft.Data.Tools.Schema.CommandLineTool.Program.Run(String[] args)
2022-01-26T09:10:26.6761067Z at Microsoft.Data.Tools.Schema.CommandLineTool.Program.Main(String[] args)
同样奇怪的是,当我们在空数据库上部署项目时一切正常。当我们想在现有数据库上部署时,问题就开始了。