我的.net framework 4.0项目与外键关系有下面的数据合约。我想为.net framework 3.5项目重用相同的代码。但我错过了ForeignKey属性的错误。我如何重写.netframework 3.5的以下代码?请帮助。
using System;
using System.Collections.Generic;
Using System.ComponentModel.DataAnnotations;
Using System.ComponentModel.DataAnnotations.Schema;
namespace xyz {
[DataContract]
public class Category
{
public string category_id { get; set; }
public string category_name { get; set; }
public virtual ICollection<SubCategory> SubCategorys { get; set; }
}
[DataContract]
public class SubCategory
{
public string sub_category_id { get; set; }
public string sub_category_name { get; set; }
public virtual ICollection<SubCategory2> SubCategory2s { get; set; }
[ForeignKey("category_id")]
public virtual Category Category { get; set; }
}
[DataContract]
public class SubCategory2
{
public string sub_category2_id { get; set; }
public string sub_category2_name { get; set; }
[ForeignKey("sub_category_id")]
public virtual SubCategory SubCategory { get; set; }
}
}