我以前在 VS2010 中做过这个并且效果很好,现在在 VS2012 中,我被告知我在ne.posts.Add(post)
. 在 VS2010 中,该方法被称为AddObject()
myDataModel.post post = new myDataModel.post();
post.postauthor = author;
post.postdate = DateTime.Now;
post.postmessage = msg;
// ne is the DbContext generated from the database
ne.posts.Add(post);
ne.SaveChanges();
该posts
实体在这里没有 AddObject 方法,那么我该怎么做呢?