I am trying to create a dacpac model in code, see the snippet below. When I call the LoadFromDacpac function, I get following error:
System.TypeLoadException: Could not load type 'System.Diagnostics.Eventing.EventDescriptor' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Any help appreciated in how to resolve this. Many thanks.
Add-Type -Path 'C:\Program Files\Microsoft SQL Server\160\DAC\bin\Microsoft.SqlServer.Dac.dll'
Add-Type -Path 'C:\Program Files\Microsoft SQL Server\160\DAC\bin\Microsoft.SqlServer.Dac.Extensions.dll'
$dacpacFilePath = 'C:\Users\dominic\Documents\SQL Server Management Studio\DAC Packages\AdventureworksLT.dacpac'
$modelOptions = New-Object Microsoft.SqlServer.Dac.Model.ModelLoadOptions
#Following call results in error:
$model = [Microsoft.SqlServer.Dac.Model.TSqlModel]::LoadFromDacpac($dacpacFilePath, $modelOptions)