# IT:AD:EF/CodeFirst:HowTo:Define/Models/Relationships/Examples/1-0..1 # * [[../|(UP)]] {{indexmenu>.#2|nsort tsort}} An invoice could be for the guy at the counter, or could be for a purchase that is to be shipped out. Therefore the invoice's Shipping Address (of which there is only 1) is optional: invoice "1" ..> "1" "Address": Optional Shipping Addr user "1" ..> "1" "Address": Optional Home Addr ## Process ## ## Process //////1-0..1: modelBuilder.Entity() //The property is called Shipping Address, but is backed //by an Address entity .HasRequired(i => i.ShippingAddress) .WithMany() //As the address is probably a reference to the //User's 'home' address, we turn off cascade delete. .WillCascadeOnDelete(false); //As the Address table is shared between different //entities, we can't put on it a UserFK or InvoiceFK //or means to navigate back to the owner table. //so avoid .WithRequired()