2

I'm sure this should be simple but I cant work it out. Project setup Visual Studio database project with references to master, msdb and another dacpac. It is the additional dacpac that is of interest.

For various reasons I will not go into here, I cannot make changes to the database represented by the dacpac.

Scenario There is a table in here I need to perform an alter on, it is missing a couple of required audit columns. I don't know how they are missing it must have been an oversite. So what I want to be able to do is correct this in my project by essentially issuing an alter table and add these columns. I don't appear to be able to do this as a pre-deployment script as anything that is then dependant on this throws compile time errors SQL71501 unresolved references. I don't appear to be able to add it as a table and have it reapply the migration as this results in an SQL71508 error.

Any suggestions would be greatly appreciated.

I would prefer to avoid adding an additional table to perform this extension.

JSW
  • 116
  • 2
  • 9
  • When you say that columns are missing -- you mean that the referenced dacpac doesn't accurately reflect the schema of the real database, correct? – Steven Green Feb 01 '17 at 14:44
  • Sorry so it is my project that references the dacpac that needs to add additional columns to a table that is created by the referenced dac pac. So the dacpac accuratly reflects the known state of the database. This current project needs to build on top of it and extend it. So for context this is a product migration so the dacpac can be thought of as the current production version of the database and the project is the next version. – JSW Feb 01 '17 at 22:31
  • Your comment has left me more confused now. A database project represents the state of a database at a given time. If you include a database reference to a dacpac file in "same database" mode, then the contents of that dacpac file are considered to be part of the database definition, but you cannot override the definition of the contents of the dacpac file in the project. I think the answer here is that you need to restructure your solution a bit, but I don't know enough about your scenario to tell you how, exactly, it should look. Please provide more info. – Steven Green Feb 02 '17 at 01:23
  • How about creating a new database from the dacpac, changing the table, and then creating a new dacpac based on this and use this instead? – David Atkinson Feb 04 '17 at 00:26
  • 1
    I have this same problem. Columns added in the pre-deployment script aren't counted as existing when compiling other schema objects. I haven't found any solution so far that doesn't involve altering the table in the external reference that I don't want to alter. – BenDoingCoding Oct 16 '17 at 20:36
  • Did you ever find a solution to this? – MplsAmigo Aug 19 '19 at 17:19

0 Answers0