I'd like to do something similar to EF Code First 0..1 to 0..1 relationship but in EF Core rather than EF 5.
Essentially I want the following relationships, given these models, without using a junction table
class foo {
public int FooId { get; set; }
public string FooName { get; set; }
public int Foo_BarId { get; set; }
}
class bar {
public int BarId { get; set; }
public string BarName { get; set; }
public int Bar_FooId { get; set; }
}
Why is it not possible to do something like the following?
Note, FooId and BarId are Primary Keys [PK] and I'd like to set a FK relationship from Foo_BarId to BarId and similarly and FK relationship from Bar_FooId to FooId. Essentially, Foo_BarId and Foo_BarId can be null while FooId and BarId is required.
The resulting table for foo and bar would look like (i used a picture of html because its too hard to post html rendered stuff here)
Why is this not allowed? Or if it is, what are the magic commands for builder.HasOne.WithOne
?