-1

I have the following classes:

class Parent
{
    public int ID;
    public Child Child1;
    public Child Child2;
}

class Child
{
    public int ID;
    public string Data;
}

Using DbModelBuilder I have the following Fluent API code:

EntityTypeConfiguration<Parent> adrInEgrul 
    = modelBuilder.Entity<Parent>();
adrInEgrul.HasKey(x => x.ID);
adrInEgrul.HasOptional(x => x.Child1)
    .WithOptionalPrincipal();
adrInEgrul.HasOptional(x => x.Child2)
    .WithOptionalPrincipal();

All this gives me the following tables:
enter image description here

But I do need the following ones:
enter image description here

I'll be happy to get what I want just fixing Fluent API part, but have no Idea how to do it (if it's possible at all).
Will appreciate any help.

Anatolyevich
  • 671
  • 5
  • 14

1 Answers1

0

After comment of callum-linington I came up with the following Fluent API code, which did the work.

EntityTypeConfiguration<Parent> adrInEgrul 
    = modelBuilder.Entity<Parent>();
adrInEgrul.HasKey(x => x.ID);
adrInEgrul.HasOptional(x => x.Child1);
adrInEgrul.HasOptional(x => x.Child2);
Anatolyevich
  • 671
  • 5
  • 14