SQL Server The reference to external elements from the source named 'xyz.dacpac' could not be resolved

yhuiod9q  于 2023-10-15  发布在  其他
关注(0)|答案(2)|浏览(98)

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)
jum4pzuy

jum4pzuy1#

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.

5w9g7ksd

5w9g7ksd2#

I'm a few years late but for anyone else coming here the specific fail reported here is "Version store out of memory" Microsoft.Isam.Esent.Interop.EsentVersionStoreOutOfMemoryException.

Our solution to use the DacPackage.Load overload which accepts a DacSchemaModelStorageType and use DacSchemaModelStorageType.Memory, i.e.

DacPackage.Load(memoryStream, DacSchemaModelStorageType.Memory);

Then the intermittent fails went away.

相关问题