Skip to content

NullReferenceException in Get-Migration in EF Core 8 #32732

@bgoodearl

Description

@bgoodearl

File a bug

See details in issue 32487
efcore/issues/32487

We've spent a fair bit of time trying to reproduce the issue with a cut-down sample, but have not been successful.

A colleague has debugged into the EF code with our client project and found where the exception is being thrown.

I created a test sample with enough entities to have the entity where the exception was thrown, but that sample does not fail.

We can share the new test sample with you and include information about where the client code is failing and the new sample is not failing, but do not want to make the new sample public.

Code that's failing:

static DeleteBehavior DefaultDeleteBehavior(IConventionSkipNavigation conventionSkipNavigation)
{
	if (!conventionSkipNavigation.ForeignKey.IsRequired)
	{
		return DeleteBehavior.ClientSetNull;
	}
	return DeleteBehavior.Cascade;
}

this throws the exception: conventionSkipNavigation.ForeignKey.IsRequired due to ForeignKey being null

This problem is a show-stopper for converting this client project to .NET 8.

Include provider and version information

EF Core version: 8.0.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 8.0
Operating system: Windows 10
IDE: Visual Studio 2022 17.8.3

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions