【问题标题】:EF code Model for e-tender system in MVC4MVC4中电子招标系统的EF代码模型
【发布时间】:2014-05-28 07:27:20
【问题描述】:

我正在构建招标板

这里是描述: 在我的简单会员角色表中,我有: (管理员、投标人、提供商、会员)

管理:他有权将普通用户角色从“会员”更改为“供应商并在招标组织批准后证明中标者。

供应商:普通用户将被指定为“会员”,并由管理部门激活为供应商,然后他们可以投标任何他们想要的项目。

项目:由招标组织用户创建每个项目都有许多要求

要求:每一项都与项目相关。

招标:这里我的问题实际上是招标是“国家的部委,必须在系统中设置”,但每个部委显然都有很多用户“经理,每个人说 5 个”谁会投票供应商。经理只能投票给同一部门下的供应商。

我想念其他桌子吗?

另外我真的不知道如何用关系和(UserprofileTbale 和 Role Table)来构造所有表: 这是我的尝试,请帮助我。

我的 DBContext:

 public class ProjectContext : DbContext
{
    public ProjectContext()
        : base("OTMSProjects")
    {
    }

    public DbSet<ProjectEntry> Entries { get; set; }
    public DbSet<Requiernments> RequiernmentEntries { get; set; }
    public DbSet<Supplier> Suppliers { get; set; }
    public DbSet<Tender> Tenders { get; set; }
    public DbSet<UserProfile> UserProfiles { get; set; }
    //public DbSet<UserRoles> UserRoles { get; set; } // do I have to set this too?
}}

我的桌子:

     public class ProjectEntry
   {
    [Key]
    public int ID { get; set; }
    [Required]
    public string ProjectName { get; set; }
    public string Description { get; set; }
    public string Statue {get; set; }
    public string UplodedFiles { get; set; }
    public string Budget { get; set; }
    public string EstimateTime { get; set; }
    public string Criterias { get; set; }
    public DateTime? DueDate { get; set; }


    // Relations  with others tables

    public virtual Tender Tender { get; set; }// every  project have only one tender
    public virtual ICollection<Supplier> Suppliers { get; set; } // every  project have one or more  supplier 
    public virtual ICollection<Requiernments> Requirements { get; set; }

} 

........

   public class Requiernments
    {
                            [Key]
                            public int RequiernmentId { get; set; }
                            public int ID { get; set; }

                            public string RequiernmentName { get; set; }

                            public string RequiernmentType { get; set; }

                            public string RequiernmentPrioritet { get; set; }

                            public float RequiernmenWhight { get; set; }
                            public string ProviderAnswer { get; set; }
                            public string ProviderComments{ get; set; }
                            public virtual ProjectEntry Projects { get; set; } 


}

........

 public class Supplier
   {
    [Key]
    public int SupplierId { get; set; }
    public int ID { get; set; }
    public int SupplierName { get; set; }
    public int SupplierCat { get; set; }

    public virtual ICollection<ProjectEntry> Projects { get; set; }
}

......

  public class Tender
   {
    [Key]

    public int TenderId { get; set; }
    public string TenderName { get; set; }
    public string TenderMinstry{ get; set; }
    public int ID { get; set; }//link to project 
    public int UserId { get; set; }  //this links to the userid in the UserProfiles table
    public virtual ICollection<ProjectEntry> Projects { get; set; }
    //public virtual ICollection<UserProfile> Userprofile { get; set; } 
    public virtual UserProfile UserProfile { get; set; }
}

我的 AccountModel 中的成员资格表由 Mvc4 中的默认创建(我只添加 RoleTable :

  [Table("UserProfile")]
  public class UserProfile
  {
    [Key]
    [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
    public int UserId { get; set; }
    public string UserName { get; set; }
    public string EmailAddress { get; set; }
    public ICollection<UserRoles> UserRoles { get; set; }

}

   [Table("webpages_Roles")]
   public class UserRoles
  {
    [Key]
    public int RoleId { get; set; }
    public string RoleName { get; set; }
    [ForeignKey("UserId")]
    public ICollection<UserProfile> UserProfiles { get; set; }
   }

也不确定如何将 Userprofile 与投标表和供应商表链接?

【问题讨论】:

  • “我想念其他桌子吗?”,这是你的问题吗? StackOverflow 不适合解决设计问题。
  • 不行,我需要检查表(一对多)和(多对多)之间的关系

标签: c# entity-framework asp.net-mvc-4 model


【解决方案1】:

不确定您是否错过了什么。但根据数据库创建,您必须遵循您的业务逻辑和规范化规则。

我的一些建议在这里: 1.项目入口 在这里,您应该单独创建一个状态表,并将其引用键作为 StatusID 提供给 ProjectEntry 表。

  1. 要求 您应该分别创建需求优先级和类型表。 为提供者问题和答案添加单独的表格。我希望您需要为单个需求存储多个问题的答案。

  2. 供应商 为供应商类别添加单独的表格

  3. 招标 单独创建Tender Ministry 表,并将其引用到tender 表中。

  4. 您应该为上传的文件创建一个表格作为文档。它应该包含 ID、ProjectId、Documentname、DocumentType、DocumentShortDescription、uplodatedDateTime 字段。

【讨论】:

  • 积分谢谢..?表格之间的关系是否正确?
  • 也不确定如何将 UserProfile 与 Tender 和供应商链接!
  • 你能告诉我有哪些类型的用户,我的意思是,有哪些角色?或者通过我的电子邮件联系我,这样我们就可以在那里进行长时间的讨论。你可以在我的个人资料上详细说明我的联系方式。
  • (管理员、投标人、提供商、会员)
  • 这里你应该创建 3 个表,1. 用户(UserID 等) 2. 角色(RoleID,RoleName) 3. UserRoles(UserId,RoleID) 这将满足您的要求。如果您有任何困惑,请告诉我。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-04
  • 2012-01-17
  • 1970-01-01
  • 1970-01-01
  • 2015-01-11
  • 2018-07-27
相关资源
最近更新 更多