Looking for a workaround for:
Error: SQL71609: System-versioned current and history tables do not have matching schemes. Mismatched column: 'XXXX'.
When trying to use SQL-2016 with system versions (Temporal) in SSDT for Visual Studio 2015.
I defined a base table:
CREATE TABLE [dbo].[Example] ( [ExampleId] INT NOT NULL IDENTITY(1,1) PRIMARY KEY, [ExampleColumn] VARCHAR(50) NOT NULL, [SysStartTime] datetime2 GENERATED ALWAYS AS ROW START HIDDEN NOT NULL, [SysEndTime] datetime2 GENERATED ALWAYS AS ROW END HIDDEN NOT NULL, PERIOD FOR SYSTEM_TIME (SysStartTime,SysEndTime) ) WITH (SYSTEM_VERSIONING=ON(HISTORY_TABLE=[history].[Example])) GO
(Assume that the [history] schema is correctly created in SSDT). This builds great for the first time.
If I make changes later:
CREATE TABLE [dbo].[Example] ( [ExampleId] INT NOT NULL IDENTITY(1,1) PRIMARY KEY, [ExampleColumn] CHAR(50) NOT NULL,
Then the assembly will complete with the error message above. Any change in data type, length, precision or scale will result in this error. (Including a change from VARCHAR to CHAR and VARCHAR(50) to VARCHAR(51) , changing NOT NULL to NULL does not result in an error.) Running Clean does not fix.
My current workaround is to make sure I have the latest version installed in the original control, then open SQL Server Object Explorer, expand the Projects - XXXX folder Projects - XXXX and navigate to the affected table, and then delete it. Then I need to restore the code (which removes the SSDT) ββfrom the original control. This procedure is tiring, dangerous, and not what I want to do.
Has anyone found a way to fix this? This is mistake?
I am using Microsoft Visual Studio Professional 2015, version 14.0.25431.01 Update 3 with SQL Server data tools 14.0.61021.0.