无法解析来自名为“ xyz.dacpac”的源中的外部元素的引用

时间:2019-03-06 17:25:48

标签: c# sql-server dacpac dac

我正在使用Microsoft.SqlServer.Dac.dll以编程方式部署我的dacpac。即使我在目标位置包括了所有供参考数据库项目使用的dacpac,我仍然得到“无法解析来自名为'xyz.dacpac'的源中对外部元素的引用”。

最终,部署失败。下面是堆栈跟踪。

ERROR : The reference to external elements from the source named 'xyz.dacpac' could not be resolved, because no such source is loaded. 
ERROR : The reference to external elements from the source named 'xyz.dacpac' could not be resolved, because no such source is loaded. 
INFO  : Initializing deployment (Failed)  
ERROR : Version store out of memory (cleanup already attempted)  Microsoft.Isam.Esent.Interop.EsentVersionStoreOutOfMemoryException: Version store out of memory (cleanup already attempted)
   at Microsoft.Isam.Esent.Interop.Api.Check(Int32 err)
   at Microsoft.Isam.Esent.Interop.Api.JetUpdate(JET_SESID sesid, JET_TABLEID tableid, Byte[] bookmark, Int32 bookmarkSize, Int32& actualBookmarkSize)
   at Microsoft.Isam.Esent.Interop.Update.Save(Byte[] bookmark, Int32 bookmarkSize, Int32& actualBookmarkSize)
   at Microsoft.Data.Tools.Schema.SchemaModel.ModelStore.EseResultSet.Update(Action action)
   at Microsoft.Data.Tools.Schema.SchemaModel.ModelStore.ForwardModelRelationship.ReplaceNonComposedElement(StorageResultSet relEntryRow, ModelElement newElement)
   at Microsoft.Data.Tools.Schema.SchemaModel.ModelStore.RelationshipEntry.set_Element(IModelElement value)
   at Microsoft.Data.Tools.Schema.SchemaModel.DataSchemaModel.ReferenceLinker.ResolveInternalElementReferences()
   at Microsoft.Data.Tools.Schema.SchemaModel.DataSchemaModel.LoadExternals(TextReader input, String fileName, String logicalSourceName, IList`1 externalPartsSubstitution, Boolean suppressErrorsForMissingDependencies)
   at Microsoft.Data.Tools.Schema.SchemaModel.DataSchemaModel.AddReference(CustomSchemaData customData)
   at Microsoft.Data.Tools.Schema.SchemaModel.DataSchemaModel.OnCustomDataAdded(CustomSchemaData customData)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlSchemaModel.OnCustomDataAdded(CustomSchemaData customData)
   at Microsoft.Data.Tools.Schema.SchemaModel.DataSchemaModel.AddCustomData(CustomSchemaData customData, Boolean raiseEvents)
   at Microsoft.Data.Tools.Schema.Sql.Deployment.DacpacHeaderLoader.LoadReferences(ErrorManager errors, String packagePath)
   at Microsoft.Data.Tools.Schema.Sql.Deployment.DacpacHeaderLoader.Load(ErrorManager errors)
   at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentEndpointPackage.OnLoad(ErrorManager errors, DeploymentEngineContext context)
   at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.PrepareModels()
   at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.InitializePlanGeneratator()
   at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.CreateController(Action`1 msgHandler)
   at Microsoft.SqlServer.Dac.DacServices.CreateController(SqlDeployment deploymentEngine, ErrorManager errorManager)
   at Microsoft.SqlServer.Dac.DeployOperation.c__DisplayClass3.c__DisplayClass5.b__1()
   at Microsoft.Data.Tools.Schema.Sql.Dac.OperationLogger.Capture(Action action)
   at Microsoft.SqlServer.Dac.DeployOperation.c__DisplayClass3.b__0(Object operation, CancellationToken token)
   at Microsoft.SqlServer.Dac.Operation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
   at Microsoft.SqlServer.Dac.ReportMessageOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
   at Microsoft.SqlServer.Dac.OperationExtension.CompositeOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
   at Microsoft.SqlServer.Dac.OperationExtension.CompositeOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
   at Microsoft.SqlServer.Dac.DeployOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
   at Microsoft.SqlServer.Dac.OperationExtension.Execute(IOperation operation, DacLoggingContext loggingContext, CancellationToken cancellationToken)
   at Microsoft.SqlServer.Dac.DacServices.InternalDeploy(IPackageSource packageSource, Boolean isDacpac, String targetDatabaseName, DacDeployOptions options, CancellationToken cancellationToken, DacLoggingContext loggingContext, Action`3 reportPlanOperation, Boolean executePlan)
   at Microsoft.SqlServer.Dac.DacServices.Deploy(DacPackage package, String targetDatabaseName, Boolean upgradeExisting, DacDeployOptions options, Nullable`1 cancellationToken)
   at DacpacService.DeployDacPac(String connectionString, String dacpacName, IDictionary`2 sqlCmdParams, ModalProgressDialog dialog)

1 个答案:

答案 0 :(得分:0)

通常,这是引用链接的问题。如果您有一个引用另一个(B.dacpac)的项目(A.dacpac),则显然需要在整个项目中包括B.dacpac。

但是,如果B.dacpac引用X.dacpac,Y.dacpac和ThirdParty.dacpac,则由于缺少引用,如果项目部署中未包含这些错误,则会出现错误。

但是,如果您实际上拥有A.dacpac和B.dacpac之间所需的所有项目,并且不需要引用X,Y或ThirdParty中的任何内容,则可以将项目A中的未解析引用抑制为是的,这些缺失的引用将被忽略。