0

I need to configure multiple foreign key 1:1 relationships in single entity, I have gone through so many posts, Please check below code for your reference. Please help me to configure the same in entity framework.

public class Institution
{
    public Institution()
    {
        InstitutionId = Guid.NewGuid().ToString("N");
    }
    public string InstitutionId { get; set; }
    public string InstutionName { get; set; }
    public string BackgroundImage { get; set; }
    public string InstitutionCode { get; set; }
    public int Logo { get; set; }

    public string AddressId { get; set; }
    [ForeignKey("AddressId")]
    public virtual Address Address { get; set; }

    public string ServerId { get; set; }
    [ForeignKey("ServerId")]
    public virtual Server InstitutionServer { get; set; }
}

Thanks in advance,

Naveen Bathina
  • 404
  • 1
  • 6
  • 25
  • What have you tried? I don't see a question there. – David Browne - Microsoft Dec 31 '17 at 16:43
  • SQL server can't do true 1 to 1. See [here](https://stackoverflow.com/questions/10292355/how-do-i-create-a-real-one-to-one-relationship-in-sql-server), but you can configure code first fluently to get what you need: http://www.entityframeworktutorial.net/code-first/configure-one-to-one-relationship-in-code-first.aspx – Steve Greene Jan 01 '18 at 16:56

0 Answers0