c# 4.0 - Code First ForeignKeyAttribute on property … on type … is not valid -


this parent class

public class artist {     public int artistid { get; set; }      [required]     [stringlength(200, minimumlength = 3)]     public string name { get; set; }      public virtual  list<album> albums { get; set; }      public virtual  artistdetails artistdetails {get;set;}  } 

this child class..

public class artistdetails {     [key()]     [foreignkey("artist")]     public int artistid { get; set; }      public string bio { get; set; }      public virtual  artist artist { get; set; } } 

when run solution shows following error...

the foreignkeyattribute on property artistid on type entityframeworkdemo.models.artistdetails not valid. navigation property artist not found on dependent type entityframeworkdemo.models.artistdetails. name value should valid navigation property name.

please me out. in advance.


Comments