EntitySplittingMissingPropertiesMainFragment does not take owned navigations/complex properties into account
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
We have a model validation check to make sure that the main table has at least one non-key property on it (EntitySplittingMissingPropertiesMainFragment). This only looks at regular properties, and does not take owned navigations/complex properties into account. When these are mapped to column(s) on the main table, the check should not throw.
Minimal repro
```c#
await using var context = new BlogContext();
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();
public class BlogContext : DbContext
{
public DbSet Blogs { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseSqlServer("Server=localhost;Database=test;User=SA;Password=Abcd5678;Connect Timeout=60;ConnectRetryCount=0;Encrypt=false")
.LogTo(Console.WriteLine, LogLevel.Information)
.EnableSensitiveDataLogging();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity(b =>
{
b.OwnsMany(p => p.Addresses, b => b.ToJson());
b.SplitToTable("Phonenumbers", b => b.Property(p => p.Phonenumber));
});
}
}
public class Blog
{
public int Id { get; set; }
// public string Name { get; set; } // Without this model validation throws although Addresses is mapped
public string Phonenumber { get; set; }
public List
Addresses { get; set; }}
public class Address
{
public string Street { get; set; }
}
```
Contributor guide
Assessment
This issue has not been assessed yet.