Scaffolding the following schema in a project with NRT enabled:
CREATE TABLE Principal
(
Id INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
);
CREATE TABLE Dependent
(
Id INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
PrincipalId INT NOT NULL,
CONSTRAINT FK_A_B FOREIGN KEY (PrincipalId) REFERENCES [Principal](Id)
);
CREATE UNIQUE NONCLUSTERED INDEX [IX_Dependent_PrincipalId] ON [Dependent] ([PrincipalId] ASC);
... generates the following CLR type for Principal:
public partial class Principal
{
public int Id { get; set; }
public virtual Dependent Dependent { get; set; } = null!;
}
The Dependent navigation property should be nullable.
Raised by @AFract in ErikEJ/EFCorePowerTools#1298