Note that there are some explanatory texts on larger screens.

plurals
  1. PO.NET MVC One-to-One relationship
    primarykey
    data
    text
    <p>I have an Expression of Interest Form which uses the following model</p> <pre><code>public class dsExpressionOfInterest { public int dsExpressionOfInterestID { get; set; } [Required(ErrorMessage = "Please enter a Date")] [DataType(DataType.Date)] [Display(Name = "Date")] public DateTime Date { get; set; } [Required(ErrorMessage = "Please enter the Contact Person")] [Display(Name = "Contact Person")] public string ContactPerson { get; set; } [Required(ErrorMessage = "Please enter the Telephone Number")] [Display(Name = "Telephone")] public string Telephone { get; set; } [Required(ErrorMessage = "Please enter the nature of the query")] [Display(Name = "Nature of query")] public string NatureOfQuery { get; set; } public virtual dsRegistration dsRegistration { get; set; } } </code></pre> <p>I also have Registration Form which has the following model</p> <pre><code>public class dsRegistration { public int dsRegistrationID { get; set; } public int dsExpressionOfInterestID { get; set; } [Display(Name = "SLA")] public bool SLAReceived { get; set; } [DataType(DataType.Date)] [Display(Name = "Date Received")] public DateTime? SLAReceivedDate { get; set; } public virtual dsExpressionOfInterest dsExpressionOfInterest { get; set; } } </code></pre> <p>My problem is I am unsure of how to set the relationship between these two models. You must have a record in the Expression Of Interest Table before a Registration Record can be created.</p> <p>At the minute I am getting the error</p> <pre><code>Unable to determine the principal end of an association between the types </code></pre> <p>In effect its a One-to-One relationship on dsExpressionOfInterestID</p> <p>Do I need to use data annotations, and if so can someone point me in the right direction please?</p>
    singulars
    1. This table or related slice is empty.
    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.
    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