我在VS 2012中使用EF 5。我尝试将新记录保存到表中,但未保存在表中,也没有引发错误。请帮忙 。我附上我的代码。EF 5在调用保存更改时未保存更改
using (TestEntities context = new TestEntities(new TestEntityConnectionManager("Testconn").ConnectionString))
{
var newCan = new Can
{
CanGUID = new Guid(canGuid),
CanName = canName,
CanDescription = canDescription,
DesignCandidateID = designCandidateId,
MigrationDataXml = migrationDataXml,
PersonID = 1,
LastModifiedPersonID = 1,
CreationDate = DateTime.Now,
LastModifiedDate = DateTime.Now,
};
context.Cans.AddObject(newCan);
var paramOut = context.SaveChanges();
retval = paramOut.ToString();
你能展示整个方法吗?我没有看到任何明显的,其他似乎你使用ObjectContext版本,并建议使用DbContext。 – Justin
嗨贾斯汀,这个方法中没有其他的东西,方法有一些参数,我把它作为值传递给新的newCan类,如上面在我的代码片段中所示 –
把它放到try catch中,请告诉我们什么是异常 – kkocabiyik