I'm using EF6 Code First to work. First I created 2 class:
public class Course
{
public int Id { get; set; }
public string Title { get; set; }
public ICollection<Tag> Tags { get; set; }
}
public class Tag
{
public int Id { get; set; }
public string Name{ get; set; }
public ICollection<Course> Courses { get; set; }
}
After add-migration and update-database, I have 3 table Courses, Tags and TagCourses. But I dont have TagCourse class in project. How can I add new fields like Details on TagCourses and CRUD this joined table?
This might work for you
public class Course
{
public int Id { get; set; }
public string Title { get; set; }
public ICollection<TagCourse> TagCourses{ get; set; }
}
public class TagCourse
{
public int CourseId {get;set; }
public int TagId {get;set; }
public string Details {get;set; }
}
public class Tag
{
public int Id { get; set; }
public string Name{ get; set; }
public ICollection<TagCourse> TagCourses { get; set; }
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.