namespace WebApplication1.Models { public class GuestbookDB { GuestbookEntities1 db = new GuestbookEntities1(); //GuestbookEntities1: 資料庫,如一個公司別的資料庫 public void Create(string name, string content) { Contents NewData = new Contents(); //Contents: 資料庫底下的一個Table NewData.name = name; NewData.content = content; db.Contents.Add(NewData); db.SaveChanges(); } public void Create(Contents NewData) { db.Contents.Add(NewData); db.SaveChanges(); } } }
[훈련]ASP.NET MVC 5 - 엔티티 프레임 워크 1
코멘트를 남겨주세요