我正在使用VS2010中http://sqlite.phxsoftware.com提供的SQLite包装器
这是我正在使用的代码
static void Main(string[] args)
{
INFO inf = INFO.CreateINFO("test5", 123);
TestDBEntities3 entity = new TestDBEntities3();
entity.Connection.Open();
entity.Connection.BeginTransaction();
var result = from i in entity.INFOes
where i.Name.Equals(inf.Name)
select i;
if (result.Count() == 0)
entity.AddToINFOes(inf);
entity.SaveChanges(true);
entity.Connection.Close();
}
当我执行代码数据时,请不要持久保存到数据库中。我正在检查App.config文件的连接字符串中提到的正确的数据库。
另外,我可以在不更改主键数据的情况下重新运行查询,并且不会发生主键冲突。
但是在在线调试期间
entity.Connection.Close();
“实体”中有新创建的记录,但未保存。
谢谢
最佳答案
您是手动开始事务的,所以您还必须提交它...
关于c# - 数据无法使用 Entity Framework 持久保存到SQLite中的表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6686134/