I'm trying to use Entity Framework 4 for a small database application I'm writing to keep record of downloaded files. When running the application I set a break point after the tableName.Add() method, before the .SaveChanges() method and I can see the data saved into the entity; then I have another break point after calling the .SaveChanges() method, and look into the database to find there is no record saved to it. I have found a lot of similar questions, but I have not found the solution to my particular problem. Here is the code:
public void StartNewDownload(string FileID)
{
DateTime startTime = DateTime.Now;
FilesDBEntities db = new FilesDBEntities();
int startedID = (from dr in db.tblDownloadResults
where dr.Value.Equals("Started")
select dr.ResultID).First();
tblDownloads myDownload = new tblDownloads { FileID = FileID, StartDateTime = startTime, ResultID = startedID };
db.tblDownloads.Add(myDownload);
db.SaveChanges();
}
Any help is appreciated.
Thanks!
((IObjectContext)ctx).ObjectContext).Connection.ConnectionStringwhich will tell you what database you are hitting.