问题描述
我有一个使用 .NET Framework 4.7.2 和 sql Server 2014 作为后端的 ASP.NET MVC 项目。我使用 Entity Framework v6.0.0 和代码优先的方法来访问数据库中的数据。
这里是表和模型类:
表:[国家/地区]
CountryId
SVGImageId
PNGImageId
IsPublished
CreatedBy
CreatedDate
UpdatedBy
UpdatedDate
表格:[国家/地区组]
CountryGroupId
IsPublished
CreatedBy
CreatedDate
UpdatedBy
UpdatedDate
表:[CountryGroupAssociatedCountries]
CountryGroupId
CountryId
Country.cs:
public class Country : BaseEntity
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int CountryId { get; set; }
public virtual ICollection<CountryContent> CountryContent { get; set; }
public int? SVGImageId { get; set; }
[ForeignKey("SVGImageId")]
public Image SVGImage { get; set; }
public int? PNGImageId { get; set; }
[ForeignKey("PNGImageId")]
public Image PNGImage { get; set; }
public ICollection<SystemUser> Users { get; set; }
public virtual ICollection<CountryGroup> CountryGroups { get; set; }
public bool IsPublished { get; set; }
public virtual ICollection<Article> RelatedArticles { get; set; }
public virtual ICollection<TaxTag> RelatedTaxTags { get; set; }
public virtual ICollection<SystemUserAssociatedCountries> SystemUserAssociatedCountries { get; set; }
public virtual ICollection<Province> Provinces { get; set; }
}
public class CountryGroup : BaseEntity
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int CountryGroupId { get; set; }
public ICollection<CountryGroupContent> CountryGroupContent { get; set; }
public ICollection<Country> Countries { get; set; }
public ICollection<Article> RelatedArticles { get; set; }
public bool IsPublished { get; set; }
public bool IsFilterallowed { get; set; }
}
我正在尝试使用实体框架方法检查表 CountryId
中是否存在 [CountryGroupAssociatedCountries]
。
任何人都可以通过提供解决此问题的指导来帮助我吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)