In terms of [InverseProperty("Foo")] you indicate to EF that Bar.Foo and Foo.Bars are paired properties from one to many associations, so clear.
Then there is Foo.MainBar and Bar.OldFoo . EF does not know how they are connected. They can be combined into a one-to-one association, they can be independent, i.e. With "multiple" plurality on the other hand. Therefore you must say EF.
I assume that the properties are independent, i.e. that a Bar can have OldFoo without requiring that this Bar be a Foo MainBar at the same time. Then it is enough to provide EF with information about one of the properties:
modelBuilder.Entity<Bar>().HasOptional(f => f.OldFoo).WithMany() .HasForeignKey(f => f.OldFooId);
or
modelBuilder.Entity<Foo>().HasOptional(f => f.MainBar) .WithRequired(b => b.OldFoo)
Since there are no inverse properties paired with these "one" ends of associations, you cannot do this with data annotations (there are no properties to decorate with attributes).
source share