SQLite를 기본 데이터베이스로 사용하는 Entity Framework (.NET 4.0)를 사용하고 있는데 데이터베이스에 일부 변경 내용을 커밋하려고하면 예외가 발생합니다.SQLite를 사용하는 Entity Framework 예외 : 기본 공급자가 Commit시 실패했습니다
커밋 할 때 기본 공급자가 실패했습니다.
스택 추적 :
// Gets more followers for the competitor and updates the database
List<Follower> moreFollowers = GetMoreFollowers(competitor);
// Add the new followers to the database
using (MySystemEntities db = new MySystemEntities())
{
try
{
foreach (Follower f in moreFollowers)
{
db.AddToFollowers(f);
}
db.SaveChanges();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
는이 코드 조각이 5,000 추종자의 배치에 와서 그것의 내부 MyService
입니다 :
System.Data.EntityException: The underlying provider failed on Commit. ---> System.Data.SQLite.SQLiteException: The database file is locked
database is locked
at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt)
at System.Data.SQLite.SQLiteDataReader.NextResult()
at System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, CommandBehavi
or behave)
at System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()
at System.Data.SQLite.SQLiteTransaction.Commit()
at System.Data.EntityClient.EntityTransaction.Commit()
--- End of inner exception stack trace ---
at System.Data.EntityClient.EntityTransaction.Commit()
at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
at MySystem.MySystemService.UpdateFollowersAndUsers() in C:\Path\To\MySystem\MySystemService.cs:line 295
내 코드는 매우 간단하다 위의 예외가 발생합니다. 그러나 동일한 코드 스 니펫을 Main
함수로 가져 와서 몇 명의 팔로어를 수동으로 추가하면 더 이상 예외가 발생하지 않고 추종자가 내 데이터베이스에 성공적으로 추가됩니다. 분명히 데이터베이스 파일이 잠겨 있습니다.이 문제의 원인은 무엇입니까?
하나의 추종자를 추가하고 커밋 한 다음 다음을 추가 할 때 처음에는 5000을 추가 한 다음 커밋 할 때 작동한다는 것을 의미합니까? – Yahia
아니, 나는 'moreFollower'리스트에 5-6 명의 추종자를 추가하는 것을 어렵게하고 그 다음에 같은 코드를 사용하여 작동한다는 것을 의미한다. 'db.SaveChanges()'를'foreach' 루프 안에서 움직이려고했지만 같은 예외가 있습니다. – Kiril