Asp.net mvc 4 先用不同的实体编码

Asp.net mvc 4 先用不同的实体编码,asp.net-mvc-4,ef-code-first,Asp.net Mvc 4,Ef Code First,我有三个模型类和三个视图。模型如下所示 public class BASLPApplicationFormModel { [Key] [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public int BASLPApplicationID { get; set; } public string BAS

我有三个模型类和三个视图。模型如下所示

 public class BASLPApplicationFormModel
        {
            [Key]
            [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
            public int BASLPApplicationID { get; set; }


            public string BASLPApplicationNo { get; set; } 

            public string ApplicantName { get; set; }

            [DataType(DataType.Date)]
            [Display(Name = "Date of Birth", Prompt = "DD/MM/YYYY")]
            public DateTime DateOfBirth { get; set; }        


            [Required]
            [Display(Name = "Email-ID")]        
            public string EmailID { get; set; }

}
第二

  public class DPPHIApplicationFormModel
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
        public int DPPHIApplicationID { get; set; }


        public string DPPHIapplicationNo { get; set; }

        [Required]
        [Display(Name = "Name of Applicant")]
        [DataType(DataType.Text)]
        public string Name { get; set; }

        [Required]
        [Display(Name = "Expansion of Initial")]
        [DataType(DataType.Text)]
        public string InitialExpansion { get; set; }


        [DataType(DataType.Date)]
        [Display(Name = "Date of Birth", Prompt = "MM/DD/YYYY")]
        public DateTime DateOfBirth { get; set; }



        [Required]
        [Display(Name = "Email-ID")]
        [DataType(DataType.EmailAddress)]
        public string EmailID { get; set; }
}
第三

    public class DTYDHHApplicationFormModel
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
        public int DTYDHHApplicationID { get; set; }    


        public string DTYDHHAapplicationNo { get; set; }

        [Required]
        [Display(Name = "Name of Applicant")]
        [DataType(DataType.Text)]
        public string name { get; set; } 



        [RegularExpression("^([0-9]+)$", ErrorMessage = "Invalid Phone Number")]
        [DataType(DataType.PhoneNumber)]
        [Display(Name = "Land Line Number")]
        public string Phone { get; set; }    

        [Required]
        [Display(Name = "Email-ID")]
        [DataType(DataType.EmailAddress)]
        public string EmailID { get; set; }
}
电子邮件模型

[Table("Emails")]
    public class UserEmails
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        public string UserEmailID { get; set; }
    }
在这里,用户与任何表单交互,并相应地提交表单


我想让所有的电子邮件条目到我的电子邮件表使用代码优先的方法,请告诉我如何才能实现

看看这一系列的三篇博文:

  • 希望这有帮助