Discrepancy Model vs DB

Hi, my model (dgp file) was out of sync with my database due to some changes done directly in database. I'm trying to get Model and Db back in sync. All but 1 issue have been resolved. Database is MS SQL Server 2016.

The way I check to see that all is in sync is: In Data Modeler with my dgp open, I do a "Merge" (Compare projects) with a dgp that has just been created from the current database. I get one 1 issue:

ALTER TABLE [RemoteUnit] DROP COLUMN [ID]
GO

ALTER TABLE [RemoteUnit] ADD [ID]
  NVARCHAR(15) NOT NULL
GO  

I cannot see in Model and Database that there actually is difference, and the reported Table.FieldName look correct too me. Maybe I'm overlooking something?

The Table.FieldName info from my main Model:

The Table.FieldName info from model just created from Database:

The DDL from my database:

CREATE TABLE dbo.RemoteUnit (
    ID NVarChar(15) NOT NULL,
    IMEI NVarChar(15) NOT NULL,
    SIM1 NVarChar(20),
    SIM2 NVarChar(20),
    "State" NVarChar(30),
    LastStateChangeUTC DateTime,
    ProductModemID NVarChar(20) NOT NULL,
    LastActivityUTC DateTime,
    InUse Bit NOT NULL,
    Latitude Float,
    Longitude Float,
    Elevation Float,
    DataJson NVarChar(4000), 
    CONSTRAINT PK_RemoteUnit PRIMARY KEY CLUSTERED (
      ID
    )
)
GO
ALTER TABLE dbo.RemoteUnit
  ADD CONSTRAINT DF_RemoteUnit_InUse DEFAULT (1) FOR InUse
GO
ALTER TABLE dbo.RemoteUnit WITH CHECK ADD CONSTRAINT FK_ProductModem_RemoteUnit FOREIGN KEY (ProductModemID)
  REFERENCES dbo.ProductModem (ProductID)
  ON DELETE NO ACTION 
  ON UPDATE NO ACTION
GO
CREATE UNIQUE INDEX U_RU_IMEI
 ON dbo.RemoteUnit(IMEI)
GO

Any hints to share on why I see the reported difference when "Compare Projects" is used?

Internally, Data Modeler compares two fields based on an internal id. This is needed, for example, to know that a field has been renamed.

So, my guess is that internally those two ID fields have different internal ids (they were created at different times, independently from each other).

Thank you Wagner,

Ok, I'll generate a new project from the existing database and manually move my diagrams over to the new one then. And then make sure all new changes are made from the model.

Have a great day!

1 Like