I have two tables:
Here's question: Is it possible to express this relationship in Code First?
I have found several same questions on stackoverflow, and all answers were "current version of Code First doesn't allow such relationship". I wonder does the greatest-and-latest version of Code First allow it?
create table dbo.Period
(
[Year] smallint not null,
[Month] tinyint not null,
Tariff decimal(9, 5) not null,
Id smallint not null,
constraint PK_Period_Year_Month primary key ([Year], [Month]),
constraint UQ_Period_Id unique (Id)
);
create table dbo.Act
(
PeriodId smallint not null,
Id int identity not null,
Number varchar(20) not null,
constraint PK_Act_Number primary key (PeriodId, Id),
constraint FK_Act_PeriodId@Period_Id foreign key (PeriodId) references Period(Id)
);
As you see, the Period.Id is not a primary key and it is migrated as a foreign key to Act.PeriodId (which itself is a part of primary key).Here's question: Is it possible to express this relationship in Code First?
I have found several same questions on stackoverflow, and all answers were "current version of Code First doesn't allow such relationship". I wonder does the greatest-and-latest version of Code First allow it?