Same error code with different error.
Could not import package.
Warning SQL72012: The object [PreProd_Data] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.
Warning SQL72012: The object [PreProd_Log] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.
Error SQL72014: .Net SqlClient Data Provider: Msg 102, Level 15, State 1, Line 5 Incorrect syntax near 'OPTIMIZE_FOR_AD_HOC_WORKLOADS'.
Error SQL72045: Script execution error. The executed script:
IF EXISTS (SELECT 1
FROM [master].[dbo].[sysdatabases]
WHERE [name] = N'$(DatabaseName)')
BEGIN
ALTER DATABASE SCOPED CONFIGURATION SET OPTIMIZE_FOR_AD_HOC_WORKLOADS = ON;
END
Solution
this blog will help to edit model.xml to remove Relationship command for OPTIMIZE_FOR_AD_HOC_WORKLOADS which is not necessary in SQL Server 2017 Instance.
https://blogs.msdn.microsoft.com/azuresqldbsupport/2017/08/16/editing-a-bacpac-file/
Make a copy of the bacpac file (for safety in case of errors).
Change the file extension to zip, then decompress it into a folder. Surprisingly, a bacpac is actually just a zip file, not something proprietary and hard to get into.
Find the model.xml file and edit it to remove the section that looks like this:
The relevant steps rewritten here:
Make a copy of the bacpac file (for safety in case of errors).
Change the file extension to zip, then decompress it into a folder.
Surprisingly, a bacpac is actually just a zip file, not something
proprietary and hard to get into.
Find the model.xml file and edit it to remove the section that looks
like this:
<Relationship Name="GenericDatabaseScopedConfigurationOptions">
<Entry>
<References Name="[OPTIMIZE_FOR_AD_HOC_WORKLOADS]" />
</Entry>
</Relationship>
Remove following block from model.xml
<Element Type="SqlGenericDatabaseScopedConfigurationOptions" Name="[OPTIMIZE_FOR_AD_HOC_WORKLOADS]">
<Property Name="GenericValueType" Value="2" />
<Property Name="GenericValue" Value="ON" />
</Element>
Save and close model.xml.
Now you need to re-generate the checksum for model.xml so that the bacpac doesn't think it was tampered with (since you just tampered with it). Create a PowerShell file named computeHash.ps1 and put this code into it.
Run the PowerShell script and give it the filepath to your unzipped and edited model.xml file. It will return a checksum value.
Copy the checksum value, then open up Origin.xml and replace the existing checksum.
Save and close Origin.xml, then select all the files and put them into a new zip file and rename the extension to bacpac.
Now bacpack file will is ready to import and it work for me.
Thanks.