This question is locked. New answers and comments are not allowed.
Hi,
I hope someone might be able to shed some light on this. I added 2 tables to my database, setup their primary keys (exactly the same for both) and setup the foreign key relationships based on those primary keys.
In SQL management studio it reflects correctly but as soon as I use the entity model to update from the database it goes and mismatch the foreign key relations as follows:
PrimaryKey -> PrimaryKeyTwo
PrimaryKeyTwo -> PrimaryKey
This ultimately results in errors which needs to be manually corrected.
Why would this mismatch occur since both variables are distinctly different.
I hope someone might be able to shed some light on this. I added 2 tables to my database, setup their primary keys (exactly the same for both) and setup the foreign key relationships based on those primary keys.
CREATE
TABLE
[dbo].[TestA](
[PrimaryKey] [nvarchar](2)
NOT
NULL
,
[PrimaryKeyTwo] [uniqueidentifier]
NOT
NULL
,
CONSTRAINT
[PK_TestA]
PRIMARY
KEY
CLUSTERED
(
[PrimaryKey]
ASC
,
[PrimaryKeyTwo]
ASC
)
WITH
(PAD_INDEX =
OFF
, STATISTICS_NORECOMPUTE =
OFF
, IGNORE_DUP_KEY =
OFF
, ALLOW_ROW_LOCKS =
ON
, ALLOW_PAGE_LOCKS =
ON
)
ON
[
PRIMARY
]
)
ON
[
PRIMARY
]
CREATE
TABLE
[dbo].[TestB](
[PrimaryKey] [nvarchar](2)
NOT
NULL
,
[PrimaryKeyTwo] [uniqueidentifier]
NOT
NULL
,
CONSTRAINT
[PK_TestB]
PRIMARY
KEY
CLUSTERED
(
[PrimaryKey]
ASC
,
[PrimaryKeyTwo]
ASC
)
WITH
(PAD_INDEX =
OFF
, STATISTICS_NORECOMPUTE =
OFF
, IGNORE_DUP_KEY =
OFF
, ALLOW_ROW_LOCKS =
ON
, ALLOW_PAGE_LOCKS =
ON
)
ON
[
PRIMARY
]
)
ON
[
PRIMARY
]
GO
ALTER
TABLE
[dbo].[TestB]
WITH
CHECK
ADD
CONSTRAINT
[FK_TestB_TestA]
FOREIGN
KEY
([PrimaryKey], [PrimaryKeyTwo])
REFERENCES
[dbo].[TestA] ([PrimaryKey], [PrimaryKeyTwo])
GO
ALTER
TABLE
[dbo].[TestB]
CHECK
CONSTRAINT
[FK_TestB_TestA]
GO
In SQL management studio it reflects correctly but as soon as I use the entity model to update from the database it goes and mismatch the foreign key relations as follows:
PrimaryKey -> PrimaryKeyTwo
PrimaryKeyTwo -> PrimaryKey
This ultimately results in errors which needs to be manually corrected.
Why would this mismatch occur since both variables are distinctly different.