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

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -