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(); } } }
[Ausbildung]ASP.NET MVC 5 - Entity Framework 1
Leave a Comment