C# 实体框架CF模型结构

C# 实体框架CF模型结构,c#,asp.net,asp.net-mvc,entity-framework,C#,Asp.net,Asp.net Mvc,Entity Framework,我已经在这方面工作了一段时间,但我仍然没有想出一个好主意 我有三种类型,分别是项目、用户和结果。用户和项目可以有多个结果。我现在的问题是一个结果可能有多种类型(现在有12种,而且可能会改变)。我不知道我应该如何构造这个结果唯一的共同点是一个类型和一个Id,我想为这12种不同类型中的每一种都创建一个表 到目前为止,我所拥有的是这个 项目 public class Project :ITypedEntity<ProjectType> { public int Id { get;

我已经在这方面工作了一段时间,但我仍然没有想出一个好主意

我有三种类型,分别是
项目
用户
结果
。用户和项目可以有多个结果。我现在的问题是一个结果可能有多种类型(现在有12种,而且可能会改变)。我不知道我应该如何构造这个结果唯一的共同点是一个类型和一个Id,我想为这12种不同类型中的每一种都创建一个表

到目前为止,我所拥有的是这个

项目

public class Project :ITypedEntity<ProjectType>
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Nationality { get; set; }
    public virtual ProjectType Type { get; set; }
    public string TitleEn { get; set; }
    public string TitleRo { get; set; }
    public string Acronym { get; set; }
    public string ContractNo { get; set; }
    public virtual ActivityField ActivityField {get;set;}
    public string SummaryEn { get; set; }
    public string SumarryRo { get; set; }
    public DateTime StartDate { get; set; }
    public DateTime EndDate { get; set; }
    public decimal Value { get; set; }
    public bool IsPartner { get; set; }
    public ICollection<User> Team{get;set;}
    public string Website {get;set;}
    public ICollection<INamedEntity> Results;
}
public class Result:ITypedEntity<ResultType>
    {
        public int Id { get; set; }
        public string Name{get;set;}
        public ResultType Type { get; set; }
    }
公共类项目:ITypedEntity
{
公共int Id{get;set;}
公共字符串名称{get;set;}
公共字符串{get;set;}
公共虚拟项目类型{get;set;}
公共字符串标题{get;set;}
公共字符串标题{get;set;}
公共字符串首字母缩略词{get;set;}
公共字符串ContractNo{get;set;}
公共虚拟活动字段活动字段{get;set;}
公共字符串总和{get;set;}
公共字符串sumaryro{get;set;}
公共日期时间起始日期{get;set;}
公共日期时间结束日期{get;set;}
公共十进制值{get;set;}
公共bool IsPartner{get;set;}
公共ICollection团队{get;set;}
公共字符串网站{get;set;}
公开收集结果;
}
结果

public class Project :ITypedEntity<ProjectType>
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Nationality { get; set; }
    public virtual ProjectType Type { get; set; }
    public string TitleEn { get; set; }
    public string TitleRo { get; set; }
    public string Acronym { get; set; }
    public string ContractNo { get; set; }
    public virtual ActivityField ActivityField {get;set;}
    public string SummaryEn { get; set; }
    public string SumarryRo { get; set; }
    public DateTime StartDate { get; set; }
    public DateTime EndDate { get; set; }
    public decimal Value { get; set; }
    public bool IsPartner { get; set; }
    public ICollection<User> Team{get;set;}
    public string Website {get;set;}
    public ICollection<INamedEntity> Results;
}
public class Result:ITypedEntity<ResultType>
    {
        public int Id { get; set; }
        public string Name{get;set;}
        public ResultType Type { get; set; }
    }
公共类结果:ITypedEntity
{
公共int Id{get;set;}
公共字符串名称{get;set;}
公共结果类型类型{get;set;}
}
用户

public class User:Person
    {
        public int CNP { get; set; }
        public virtual Faculty Faculty { get; set; }
        public bool IsUSAMV {get;set;}
        public virtual ICollection<INamedEntity> Results {get;set;}
        public virtual ICollection<Project> Projects {get;set;}
    }
公共类用户:个人
{
公共int CNP{get;set;}
公共虚拟教员{get;set;}
公共bool IsUSAMV{get;set;}
公共虚拟ICollection结果{get;set;}
公共虚拟ICollection项目{get;set;}
}
我不认为这有什么帮助,但我还是会粘贴它们

public interface INamedEntity:IEntity
{
    string Name{get;set;}
}
public interface ITypedEntity<TType>:INamedEntity{
    TType Type { get; set; }
}
public interface IEntity
{
    int Id { get; set; }
}
INamedEntity中的公共接口:IEntity
{
字符串名称{get;set;}
}
公共接口ITypeIdentity:INamedEntity{
t类型类型{get;set;}
}
公共界面的开放性
{
int Id{get;set;}
}
更新1 某些结果类型

public class BookChapter:INamedEntity
{
    public int Id { get; set; }
    public string Name { get; set; }
    public virtual Book Book {get;set;}
    public int PagesInChapter {get;set;}
    public string Pagination {get;set;}
}


public class Book:INamedEntity
{
    public int Id { get; set; }
    public string Name { get; set; }
    public ICollection<Person> Authors { get; set; }
    public int Year { get; set; }
    public Publisher Publisher {get;set;}
    public int NumberOfPages { get; set; }
    public string Pagination { get; set; }
    public int ISBN { get; set; }
}


public class Patent:ITypedEntity<PatentType>
{
    public int Id { get; set; }
    public string Name { get; set; }
    public virtual ICollection<Person> Authors { get; set; }
    public virtual Person Holder{get;set;}
    public string Number{get;set;}
    public virtual PatentType Type { get; set; }
}
公共类书籍章节:INamedEntity
{
公共int Id{get;set;}
公共字符串名称{get;set;}
公共虚拟图书{get;set;}
公共int页第{get;set;}章
公共字符串分页{get;set;}
}
公共类书:INamedEntity
{
公共int Id{get;set;}
公共字符串名称{get;set;}
公共ICollection作者{get;set;}
公共整数年{get;set;}
公共发布服务器{get;set;}
公共int NumberOfPages{get;set;}
公共字符串分页{get;set;}
公共整数ISBN{get;set;}
}
公共类专利:ITypedEntity
{
公共int Id{get;set;}
公共字符串名称{get;set;}
公共虚拟ICollection作者{get;set;}
公共虚拟人持有者{get;set;}
公共字符串编号{get;set;}
公共虚拟专利类型{get;set;}
}
对不起,如果问题不清楚,我会用您需要的任何其他信息更新它。
谢谢。

你调查过了吗?@HenkMollema我不知道那是什么,我会调查一下,提供并回复给你。谢谢。你能展示一下你的一些结果类型吗?完整的类。为什么它们不从
Result
?我也这么想@HenkMollema。从结果中得出它们。不妨将结果标记为抽象,然后从那个里开始使用规格,并将您的结果作为一个ICollection