linq - EntityFramework 6 in ASP.NET MVC4 Data Annotations -
i want data between db.tableas , db.tablebs using following method:
class tablea.cs:
public class tablea { [key] public int id {get;set;} public int tablebid {get;set;} public string description{get;set;} public virtual tableb tablebs{get;set;} }
class tableb.cs:
public class tableb{ [key] public int id {get;set;} public int tableaid {get;set;} public string description{get;set;} public virtual tablea tableas{get;set;} }
i have functions need tableb's data tablea , functions need tablea's data tableb. doing getting error:
unable determine principal end of association between types 'tablea' , 'tableb'. principal end of association must explicitly configured using either relationship fluent api or data annotations.
can know how data without codes below:
tableb tableb = _tablebmodel.getsingle(tablea.id); public tableb getsingle(int id) { return db.tablebs.where(e => e.id == id).firstordefault(); }
Comments
Post a Comment