Код: Выделить всё
public class Person
{
// both of these properties should refer to same jsonb column
public string ContactsJson { get; }
public Contacts Contacts { get; }
}
public class Contacts
{
public string Tel { get; }
public string Fax { get; }
}
Код: Выделить всё
modelBuilder.Entity()
.Property(x => x.ContactsJson)
.HasColumnType("jsonb")
.IsRequired();
Код: Выделить всё
modelBuilder.Entity()
.OwnsOne(x => x.Contacts, b => {
b.ToJson();
b.Property(c => c.Tel).IsRequired();
b.Property(c => c.Fax).IsRequired(false);
});
Как мне это сделать?
Подробнее здесь: https://stackoverflow.com/questions/792 ... th-ef-core