C# MVC4中电子投标系统的EF代码模型
我正在构建招标委员会应用程序,在如何使用>>MVC4中的>>实体框架构建我的模型方面,我感到有些困惑 以下是描述: 在我的简单成员角色表中,我有:C# MVC4中电子投标系统的EF代码模型,c#,entity-framework,asp.net-mvc-4,model,C#,Entity Framework,Asp.net Mvc 4,Model,我正在构建招标委员会应用程序,在如何使用>>MVC4中的>>实体框架构建我的模型方面,我感到有些困惑 以下是描述: 在我的简单成员角色表中,我有: (管理员、招标人、供应商、会员) 管理:在招标组织批准后,他有权将正常用户角色从“成员”更改为“供应商”,并证明中标人 供应商:普通用户将被指定为“成员”,并被管理部门激活为供应商,然后他们可以投标任何他们想要的项目 项目:由招标组织用户创建每个项目都有许多要求 要求:与项目相关的每一项 投标:这里我的问题实际上是投标是“国家的部门,必须在系统中设置
(管理员、招标人、供应商、会员) 管理:在招标组织批准后,他有权将正常用户角色从“成员”更改为“供应商”,并证明中标人 供应商:普通用户将被指定为“成员”,并被管理部门激活为供应商,然后他们可以投标任何他们想要的项目 项目:由招标组织用户创建每个项目都有许多要求 要求:与项目相关的每一项 投标:这里我的问题实际上是投标是“国家的部门,必须在系统中设置”,但每个部门显然都有许多用户“经理”,比如说每个部门有5名“谁将投票给供应商”。经理只能投票给同一部门下的供应商 我想念其他桌子吗? 另外我真的不知道如何使用关系以及(UserprofileTbale和Role Table)构造所有表: 这是我的尝试,帮我吧 我的数据库上下文:
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 int SupplierId{get;set;}
公共int ID{get;set;}
公共int供应商名称{get;set;}
公共int-SupplierCat{get;set;}
公共虚拟ICollection项目{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; }
}
公开招标
{
[关键]
public int TenderId{get;set;}
公共字符串TenderName{get;set;}
公共字符串{get;set;}
public int ID{get;set;}//指向项目的链接
public int UserId{get;set;}//此链接指向UserProfiles表中的UserId
公共虚拟ICollection项目{get;set;}
//公共虚拟ICollection用户配置文件{get;set;}
公共虚拟用户配置文件用户配置文件{get;set;}
}
由Mvc4中的defualt创建的我的AccountModel中的我的成员表(我仅添加角色表:
[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; }
}
[表(“用户配置文件”)]
公共类用户配置文件
{
[关键]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int UserId{get;set;}
公共字符串用户名{get;set;}
公共字符串电子邮件地址{get;set;}
公共ICollection用户角色{get;set;}
}
[表格(“网页和角色”)]
公共类用户角色
{
[关键]
public int RoleId{get;set;}
公共字符串RoleName{get;set;}
[外键(“用户ID”)]
公共ICollection用户配置文件{get;set;}
}
我也不确定如何将Userprofile与投标表和供应商表链接?不确定是否遗漏了什么。但根据数据库创建,您必须遵循业务逻辑和规范化规则 我的一些建议如下: 1.项目输入 在这里,您应该单独创建一个状态表,并将其引用键作为StatusID提供给ProjectEntry表
“我想念其他表吗?”,这是你的问题吗?StackOverflow不是设计问题的正确位置。不,我需要检查表(一对多)和(多对多)之间的关系货物积分谢谢..?表格之间的关系正确吗?我也不确定如何将用户档案与招标人和供应商联系起来!你能告诉我哪些类型的用户,我的意思是,有哪些角色吗?或者通过我的电子邮件与我联系,这样我们就可以在那里进行长时间的讨论。你可以在我的档案上修改我的联系详细信息。(管理员、招标人、供应商、会员)在这里,你应该制作3个表格,1.用户(UserID等)2.角色(RoleID,RoleName)3.用户角色(UserID,RoleID)这将满足你的要求。如果你有任何困惑,请告诉我。
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; }
}
[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; }
}