I'm failing at creating a 1 to 0..1 relationship between two tables, where the primary key is a composite key consisting of two columns.
The tables are imported to the EF with an many to many relationship, changing the relationship to 1 to 0..1 or 1 to 1 results in the following error:
Multiplicity is not valid in Role Because the Dependent Role properties are not the key properties, the upper bound of the multiplicity of the Dependent Role must be *
Primary table:
CREATE TABLE [dbo].[MeasurementBlobs] (
[MeasurementResultId] INT NOT NULL,
[ValueType] SMALLINT NOT NULL,
[Id] UNIQUEIDENTIFIER ROWGUIDCOL NOT NULL,
[Value] VARBINARY(MAX) FILESTREAM NOT NULL,
CONSTRAINT [PKMeasurementBlobs] PRIMARY KEY CLUSTERED ([MeasurementResultId], [ValueType]),
CONSTRAINT [FKMeasurementBlobsMeasurementResults] FOREIGN KEY ([MeasurementResultId]) REFERENCES [dbo].[MeasurementResults] ([Id]),
CONSTRAINT [UQMeasurementBlobsId] UNIQUE ([Id])
)
GO
Foreign key table:
CREATE TABLE [dbo].[MeasurementBlobsMeasurementClusters]
(
[MeasurementResultId] INT NOT NULL,
[ValueType] SMALLINT NOT NULL,
[MeasurementClusterId] INT NOT NULL,
CONSTRAINT [PKMeasurementBlobsMeasurementClusters] PRIMARY KEY CLUSTERED ([MeasurementResultId], [ValueType] ASC, [MeasurementClusterId] ASC),
CONSTRAINT [FKMeasurementBlobsMeasurementClustersMeasurementBlob] FOREIGN KEY ([MeasurementResultId], [ValueType]) REFERENCES [dbo].[MeasurementBlobs] ([MeasurementResultId], [ValueType]),
CONSTRAINT [FKMeasurementBlobsMeasurementClustersMeasurementCluster] FOREIGN KEY ([MeasurementClusterId]) REFERENCES [dbo].[MeasurementClusters] ([Id])
)
GO
Using table table per type inheritance is not an option.