Note that there are some explanatory texts on larger screens.

plurals
  1. PO.net mvc cyclical reference issue with entity
    primarykey
    data
    text
    <p>I know others have posted about this, but I can't find an answer that seems to match what my question is. Although I am super new to .net so I may just not understand something. </p> <p>My site has a project object, which is owned by a particular user. The project has another model for extra info that other users can add. </p> <p>My models are like:</p> <p>Project</p> <ul> <li>Project Owner FK</li> <li>Other stuff</li> </ul> <p>Information</p> <ul> <li>Project FK</li> <li>Info Owner FK</li> <li>Other stuff</li> </ul> <p>But I am getting error The referential relationship will result in a cyclical reference that is not allowed.</p> <p>I think it is upset that I have a fk to a user in both project and info. But the users are different, so I can't get rid of one. Is there a way to tell it that?</p> <p>Again, I am brand new to .net, so I'm hoping this isn't a silly question. I come from a django background, if that helps with explanation. </p> <p>Code:</p> <pre><code>public class Information { [HiddenInput(DisplayValue = false)] public int InfoID { get; set; } //user public virtual User User { get; set; } [Required(ErrorMessage = "This field is required.")] public int UserID { get; set; } //project public virtual Project Project { get; set; } [Required(ErrorMessage = "This field is required.")] public int ProjectID { get; set; } } public class Project { [HiddenInput(DisplayValue = false)] public int ProjectID { get; set; } //user public virtual User User { get; set; } [Required(ErrorMessage = "This field is required.")] public int UserID { get; set; } } </code></pre> <p>I removed all of the other non-relational fields, since those are not important. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload