[训练]ASP.NET MVC 5 - 代码优先

    //資料模型一對多關聯
    public class Guestbook
    {
        public int Id { get; set; }
        public string Content { get; set; }
        public DateTime CreateTime { get; set; }
        public Member Member { get; set; }
    }

    public class Member
    {
        [Key]
        public string Username { get; set; }
        public string Password { get; set; }
        public string Name { get; set; }
        public string Email { get; set; }

        public ICollection<Guestbook> Guestbook { get; set; }
    }
    //Code First 就是在Model定義好各欄位後,其他的Controller、View都會自動幫你產生,
    //很神奇的功能,讓你專注在寫Model的部分就好

发表评论

请注意:: 评论审核已启用,可能会耽误您的评论. 有没有必要重新提交您的评论.