[latihan]ASP.NET MVC 5 – Kode Pertama

    //資料模型一對多關聯
    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的部分就好

Tinggalkan Komentar

Harap dicatat: Moderasi komentar diaktifkan dan dapat menunda komentar Anda. Tidak perlu mengirimkan kembali komentar Anda.