0

I am using Microsoft.SqlServer.Dac.dll to deploy my dacpacs programmatically. Even though I am including all the dacpacs for the referenced database projects at the target location, I am getting "The reference to external elements from the source named 'xyz.dacpac' could not be resolved".

Eventually the deploy fails. Below is the stack trace.

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)
C Joshi
  • 11
  • 3
  • There were pending windows updates on the server which we performed and, now when we are trying, it almost succeeds all the time. But it still fails sometimes(10%) with the exact same error. – C Joshi Mar 07 '19 at 13:55

1 Answers1

0

Generally, this is a problem with reference chaining. If you have a project (A.dacpac) that references another (B.dacpac), you obviously need to include B.dacpac in the full project.

However, if B.dacpac references X.dacpac, Y.dacpac, and ThirdParty.dacpac, you will get errors if those are not included in the project deploy, because there are missing references.

However, if you actually have all of the items you need between A.dacpac and B.dacpac, and do not need to reference anything in X, Y, or ThirdParty, then you can set Suppress unresolved references in project A to True, and these missing references will be ignored.

Laughing Vergil
  • 3,706
  • 1
  • 14
  • 28
  • To add to the original post, This happens intermittently. Sometimes succeeds and then once it stops working, it keeps failing. I can't pin point the actual issue. Not sure if it is environment specific. Before, one of my teammate saw this on SQL 2008 and then another saw this today in sql 2012 that's what made me ask the community if anyone experience the issue like this... – C Joshi Mar 06 '19 at 21:12