Search code examples
sql-servertfscontinuous-integrationsql-server-data-toolsdevenv

How to avoid .dacpac project checks in CI?


I build my database project in CI using devenv.exe. All "Deploy" checkboxes in ConfigurationManager are disabled. DeployToDatabase in sqlproj file is set to False. I use devenv.exe like

devenv.exe "PathToSln\MySln.sln" /build /Release /Out "LogFile.log" 

And on each build I get error: "System-versioned current and history tables do not have matching schemas." I know what this error means, and I should live with it right now. So, the questions is: how to remove Schema Validation in the devenv.exe through Command Line?


Solution

  • Database projects always validate the schema prior to producing the dacpac file. There is no alternative to this. Also, the schema validation is unrelated to deployment -- it's checking whether the database defined by the project is internally consistent.

    All of which is to say that you need to fix the error with your temporal tables. There are three things that I can think of that could be going on here:

    • The version of SSDT installed on the machine is old and has a bug that causes this error to happen for most temporal table definitions. Ensure that your machine has the most recent version of SSDT.

    • Your project actually does contain an invalid temporal table definition. This happens if you define both the current and the history table in the project, but the two tables have a different structure. Verify that your table schemas match or that your history table is implicitly defined (i.e. the history table name is specified, but the history table itself is not defined anywhere in the project with its own create table statement).

    • You're encountering a bug with temporal tables that hasn't been fixed yet. This can happen with implicit history table definitions. Either switch to explicitly defined history tables, or work around the issue by closing VS and deleting the automatically generated DBMDL cache file that is found on disk beside the sqlproj file.