I'm trying to create a relation in two models, Courses and Assignments:
namespace MyWebApp.Core.Models
{
public class Course
{
[Key]
public int Id { get; set; }
[Required]
[RegularExpression(@"[A-Za-z]{3}\d{3}", ErrorMessage="Invalid Course ID")]
[Display(Name="Course ID")]
public string CourseSeq { get; set; }
[Required]
[Display(Name = "Course")]
public string CourseName { get; set; }
[Required]
[Display(Name = "Professor")]
public string Professor { get; set; }
public virtual ApplicationUser User { get; set; }
}
}
namespace MyWebApp.Core.Models
{
public class Assignment
{
public int Id { get; set; }
[Display(Name="Assignment")]
[Required]
public string Name { get; set; }
[Display(Name="Due on")]
public DateTime DueDate { get; set; }
[Display(Name="Description")]
public string Description { get; set; }
}
}
The UserApplication : IdentityUser (from Microsoft.AspNet.Identity) class is defined in IdentityModels which is created by default when choosing a MVC template. I've created another project in my solution (MyWebApp.Core) which will hold the Models. I'm getting an error when creating a prop (user ) which will relate the model to the user tables. Basically Assignments relates to Courses which relates to Users. For some reason I can add the using directive in the .Core project, it doesn't find it in references. I've also moved the default IdentityModels from MyApp.Web.Models to MyApp.Core.Models, which created a couple error due to missing references. Does it make sense to move the default IdentityModels to a class lib .core, and change it's namespace or is it better to keep the identity Models in .wed