it:ad:code_first:howto:define_models:relationships:examples:1-0...1

IT:AD:EF/CodeFirst:HowTo:Define/Models/Relationships/Examples/1-0..1

   //////1-0..1:
        modelBuilder.Entity<Invoice>()
            //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()

  • /home/skysigal/public_html/data/pages/it/ad/code_first/howto/define_models/relationships/examples/1-0...1.txt
  • Last modified: 2023/11/04 03:03
  • by 127.0.0.1