If a model is missing a foreign key property, you will have a NullReferenceException thrown in FKeyInfo.GetEdmMultiplicity. It would be nice if this was handled more gracefully / better logging to point at the issue.
public class MyFinanceDbContext : DbContext
{
public DbSet<Car> Cars { get; set; }
public DbSet<State> States { get; set; }
public MyFinanceDbContext(DbContextOptions options) : base(options)
{
}
}
public class Car
{
public int Id { get; set; }
// Missing: `public int StateId { get; set; }`
public virtual State State { get; set; }
}
public class State
{
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Car> Cars { get; set; }
}
I ultimately threw in some debug logging which allowed me to determine a single null entry was in the dependentStructuralProperties array
If a model is missing a foreign key property, you will have a
NullReferenceException
thrown inFKeyInfo.GetEdmMultiplicity
. It would be nice if this was handled more gracefully / better logging to point at the issue.I ultimately threw in some debug logging which allowed me to determine a single
null
entry was in thedependentStructuralProperties
array