Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaffolding with NRT generates non-nullable navigation property from principal to dependent #27496

Closed
roji opened this issue Feb 23, 2022 · 4 comments · Fixed by #27616
Closed
Assignees
Labels
area-scaffolding closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported Servicing-approved type-bug
Milestone

Comments

@roji
Copy link
Member

roji commented Feb 23, 2022

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

@ajcvickers ajcvickers added this to the 7.0.0 milestone Mar 1, 2022
roji added a commit to roji/efcore that referenced this issue Mar 10, 2022
@roji roji added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Mar 10, 2022
@ErikEJ
Copy link
Contributor

ErikEJ commented Mar 10, 2022

Patch in 6.0?

@roji
Copy link
Member Author

roji commented Mar 10, 2022

Yeah, I think it makes sense - will bring to the team for discussion.

@ajcvickers
Copy link
Member

@roji Did this go into a 6.0 patch? If so, which one?

@roji
Copy link
Member Author

roji commented Jul 6, 2022

Whoops, looks like this slipped under the radar - we didn't service this. I'll prepare a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-scaffolding closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported Servicing-approved type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants