С учетом следующих классов
Код: Выделить всё
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
private class JoinedObject
{
[Key]
public Guid Id { get; set; }
}
private class SomeClass
{
[ForeignKey(nameof(JoinedObject))]
public Guid ForeignKey { get; set; }
public JoinedObject? JoinedObject { get; set; }
}
Код: Выделить всё
var joinedObject = new JoinedObject { Id = Guid.New() };
var someObject = this.Fixture.Build()
.With(x => x.JoinedObject, joinedObject)
.Create()
Подробнее здесь: https://stackoverflow.com/questions/798 ... ationships
Мобильная версия