Код: Выделить всё
// Parent entity
public class Person
{
public Guid Id { get; set; }
public string Name { get; set; }
public Address Address { get; set; }
}
// Owned Type
public class Address {
public string Street { get; set; }
public string Number { get; set; }
}
...
// Configuration
public class PersonConfiguration : IEntityTypeConfiguration
{
public void Configure(EntityTypeBuilder builder)
{
builder.OwnsOne(person => person.Address);
}
}
...
// On Address (owned property) modified:
bool personModified = _dbContext.ChangeTracker
.Entries()
.Any(x => x.State == EntityState.Modified);
Console.WriteLine(personModified); // -> false
Код: Выделить всё
PersonКод: Выделить всё
AddressКстати. Я использую EF Core v2.1.1.
Подробнее здесь: https://stackoverflow.com/questions/514 ... ent-entity
Мобильная версия