I am trying to seed an user entity in my database. The User
entity has an owend property EmailPermissions
.
When I run the command
Thank Ivan Stoev's answer. i add some more code to easy to imagine. this is code of seed data function base on example.
Example: Entity XXX => PK will be XXXId
private void SeedUser(ModelBuilder builder)
{
builder.Entity(b =>
{
b.HasData(new User
{
Id = "37846734-172e-4149-8cec-6f43d1eb3f60",
Email = "foo@foo.foo",
UserName = "foo@foo.foo",
// more properties of User
});
b.OwnsOne(e => e.EmailPermissions).HasData(new
{
UserId = "37846734-172e-4149-8cec-6f43d1eb3f60",
Newsletter = true,
PromotionalOffers = true,
PrestationReminders = true,
PrestationOffers = true
});
});
}