2

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

 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; }
    }

在这里,用户与任何表单进行交互并相应地提交他们的表单。

我想使用代码优先方法将所有电子邮件条目添加到我的电子邮件表中,请告诉我如何实现。

4