i'm new entity framework , when i'm creating sample projects got following error .
" entity type 'studentsubject' not mapped."
following table diagram.

the issue is not generating mapping studentsubject holds records of many many mapping of student , subject tables.
but if introduce new column id table studentsubject , make primary key , remove composite primary key works. want know why happening , way did rite way in model first approach.
i can't see code how map it. note requires no fluent api mapping
public class student { public int id { get; set; } public string firstname {get; set; } public string lastname {get; set; } public virtual icollection<studentsubject> studentsubjects { get; set; } } public class subject { public int id { get; set; } public string name {get; set; } public virtual icollection<studentsubject> studentsubjects { get; set; } } public class studentsubject { [key] [column(order = 1)] public int studentid { get; set; } [key] [column(order = 2)] public int subjectid{ get; set; } public virtual student student { get; set; } public virtual subject subject { get; set; } }
Comments
Post a Comment