i use Codefirst in my project and these are my class
public class Type : Medicallexicon.Classes.TableField
{
public string Name
{ get; set; }
public string PictureURL
{ get; set; }
public int ID
{ get; set; }
public DateTime CreatedDate
{ get; set; }
public Guid UniqID
{ get; set; }
public string Description
{ get; set; }
public Language Language
{ get; set; }
}
and this my the other class
public class Language
{
public string Name
{ get; set; }
public string PictureURL
{ get; set; }
public int ID
{ get; set; }
public DateTime CreatedDate
{ get; set; }
public Guid UniqID
{ get; set; }
public string Description
{ get; set; }
}
and when add clontroller and run project rais ths error
Unable to retrieve association information for association 'Medicallexicon.Type_Language'. Only models that include foreign key information are supported. See Entity Framework documentation for details on creating models that include foreign key information.
You need a primary key on the Language class called either Id or LanguageId. Then you need to include that in your Type class, it needs this to reference the other table.
Something like this:
public class Type : Medicallexicon.Classes.TableField
{
public string Name
{ get; set; }
public string PictureURL
{ get; set; }
public int ID
{ get; set; }
public DateTime CreatedDate
{ get; set; }
public Guid UniqID
{ get; set; }
public string Description
{ get; set; }
//Association
public int LanguageId {get;set;}
public Language Language
{ get; set; }
}
and this my the other class
public class Language
{
public int LanguageId {get;set;}
public string Name
{ get; set; }
public string PictureURL
{ get; set; }
public int ID
{ get; set; }
public DateTime CreatedDate
{ get; set; }
public Guid UniqID
{ get; set; }
public string Description
{ get; set; }
}
MohammadJafa...
Participant
845 Points
244 Posts
Unable to retrieve association information for association
Apr 25, 2012 03:19 PM|LINK
hello.
i use Codefirst in my project and these are my class
public class Type : Medicallexicon.Classes.TableField
{
public string Name
{ get; set; }
public string PictureURL
{ get; set; }
public int ID
{ get; set; }
public DateTime CreatedDate
{ get; set; }
public Guid UniqID
{ get; set; }
public string Description
{ get; set; }
public Language Language
{ get; set; }
}
and this my the other class
public class Language
{
public string Name
{ get; set; }
public string PictureURL
{ get; set; }
public int ID
{ get; set; }
public DateTime CreatedDate
{ get; set; }
public Guid UniqID
{ get; set; }
public string Description
{ get; set; }
}
and when add clontroller and run project rais ths error
Unable to retrieve association information for association 'Medicallexicon.Type_Language'. Only models that include foreign key information are supported. See Entity Framework documentation for details on creating models that include foreign key information.
CodeHobo
All-Star
18647 Points
2647 Posts
Re: Unable to retrieve association information for association
Apr 25, 2012 03:24 PM|LINK
You need a primary key on the Language class called either Id or LanguageId. Then you need to include that in your Type class, it needs this to reference the other table.
Something like this:
public class Type : Medicallexicon.Classes.TableField { public string Name { get; set; } public string PictureURL { get; set; } public int ID { get; set; } public DateTime CreatedDate { get; set; } public Guid UniqID { get; set; } public string Description { get; set; } //Association public int LanguageId {get;set;} public Language Language { get; set; } } and this my the other class public class Language { public int LanguageId {get;set;} public string Name { get; set; } public string PictureURL { get; set; } public int ID { get; set; } public DateTime CreatedDate { get; set; } public Guid UniqID { get; set; } public string Description { get; set; } }Blog | Twitter : @Hattan
MohammadJafa...
Participant
845 Points
244 Posts
Re: Unable to retrieve association information for association
Apr 25, 2012 03:28 PM|LINK
hello i chanaged but rais this error
Failed to get the MetadataWorkspace for the DbContext type 'Medicallexicon.MedicalDbContext'.
MohammadJafa...
Participant
845 Points
244 Posts
Re: Unable to retrieve association information for association
Apr 25, 2012 03:30 PM|LINK
oh you are the best.
tnx