title: Self referencing loop Entity FrameWork
body: <p>I'm currently using WebApi 2.0 and EntityFrameWork and I'm having issues with it: </p>
  
  <blockquote>
    <p>Self referencing loop detected for property 'UserInfo' with type 'System.Data.Entity.DynamicProxies.UserInfo_F7C6DF3909A804C5A9AC107297C8851F4CC9DF1CCA4A689B892B6C6EBA5A6EA8'. Path '[0].User'."</p>
  </blockquote>
  
  <p>my DB is something like this: User-UserInfo and is 1-1 relationship, the PK of User is the PF in UserInfo;</p>
  
  <pre><code>public class User {    
          public int UserId { set; get; }
          public string username { set; get; }
          public string password { set; get; }
          public string name { set; get; }
          public string email { set; get; }
          public string surname { set; get; }
          public string lastName { set; get; }
          public int age { set; get; }
          public DateTime regDate { set; get; }
          public bool userType { set; get; }
  
          //we define our relationships
          //1-1 UserModel-UserInfo
          public virtual UserInfo UserInfo { set; get; }
  }
  </code></pre>
  
  <p>My UserInfo class: </p>
  
  <pre><code>public class UserInfo { 
      [Key, ForeignKey("User")]
      public int UserId { set; get; }        
      public string username { set; get; }        
      public string phone{ set; get; }        
      public string adress { set; get; }        
      public string country { set; get; }        
      public string city { set; get; }        
      public string zip { set; get; }
  
      //we define our relationships 
      //1-1 UserModel-UserInfo
      public virtual User User { set; get; }
  
  }
  </code></pre>
  
  <p>In Postman I send a Post request and register a user:</p>
  
  <pre><code>{
    "username": "otmanlicona",
    "password": "pwd1234",
    "name": "Otman",
    "email": "otmanlicona17@mail.com",
    "surname": "licona",
    "lastName": "ledezma",
    "age": 33,
    "regDate": "2017-03-01T18:10:11+00:00",
    "userType": false
  }
  </code></pre>
  
  <p>If I send a GET request I get all the users: </p>
  
  <pre><code>[
    {
      "Orders": [],
      "ReviewProducts": [],
      "UserInfo": null,
      "UserId": 7,
      "username": "otmanlicona",
      "password": "pwd1234",
      "name": "Otman",
      "email": "otmanlicona17@mail.com",
      "surname": "licona",
      "lastName": "ledezma",
      "age": 33,
      "regDate": "2017-03-01T12:10:11",
      "userType": false
    },
    {
      "Orders": [],
      "ReviewProducts": [],
      "UserInfo": null,
      "UserId": 8,
      "username": "angelsilva",
      "password": "pwd1234",
      "name": "angel",
      "email": "angelsilva@mail.com",
      "surname": "silva",
      "lastName": "borja",
      "age": 22,
      "regDate": "2017-03-01T12:10:11",
      "userType": true
    }
  ]
  </code></pre>
  
  <p>No problems so far , the problem is when I insert the UserInfo:</p>
  
  <pre><code>{
    "UserId": 8,
    "username": "angelsilva",
    "phone": "12345678",
    "adress": "550 Swallow Hill",
    "country": "USA",
    "city": "foo",
    "zip": "47-253"
  }
  </code></pre>
  
  <p>If I send another GET request I get an Exception: 
  <a href="https://imgroll.net/i/DD5M1" rel="nofollow noreferrer">Image of the error</a></p>
  
  <blockquote>
    <p>Self referencing loop detected for property 'UserInfo'</p>
  </blockquote>
  
  <p>Can anyone tell me what I'm doing wrong?,Thanks </p>
  
  <pre><code>[
    {
      "Orders": [],
      "ReviewProducts": [],
      "UserInfo": null,
      "UserId": 7,
      "username": "otmanlicona",
      "password": "pwd1234",
      "name": "Otman",
      "email": "otmanlicona17@mail.com",
      "surname": "licona",
      "lastName": "ledezma",
      "age": 33,
      "regDate": "2017-03-01T12:10:11",
      "userType": false
    },
    {
      "Orders": [],
      "ReviewProducts": [],
      "UserInfo": {
        "UserId": 8,
        "username": "angelsilva",
        "phone": "12345678",
        "adress": "550 Swallow Hill",
        "country": "USA",
        "city": "foo",
        "zip": "47-253"
      },
      "UserId": 8,
      "username": "angelsilva",
      "password": "pwd1234",
      "name": "angel",
      "email": "angelsilva@mail.com",
      "surname": "silva",
      "lastName": "borja",
      "age": 22,
      "regDate": "2017-03-01T12:10:11",
      "userType": true
    }
  ]
  </code></pre>
  
  <p>NOW I see what does Entity Framework meant by self referencing loop; What can I do so in my Get response only returns me the other values that aren't in the User Class like username,phone,address,country, etc.</p>