Inside my Asp.net MVC 3 app, using Entity Framework 6.0, I am trying to update a database table record using an asynchronous method like:
public static async Task UpdateAssetLogAsync(string assetID)
{
using (var context = new MyContext())
{
var log = await context.UploadedLogs.SingleAsync(e => e.AssetID == assetID);
if (log != null)
{
log.LastUpdatedOn = DateTime.Now;
await context.SaveChangesAsync();
}
}
}
Unfortunately code execution stops as soon as it comes to line number 5 i.e
var log = await context.UploadedLogs.SingleAsync(e => e.AssetID == assetID);
Visual Studio (2012) shows no error at all and program execution just breaks from here.
Please can anyone tell what is the issue?
[Edit] This is my connection string
<add name="MyContext" connectionString="Server=.\SQLExpress;Database=Test;Max Pool Size=80;Integrated Security=true;MultipleActiveResultSets=True" providerName="System.Data.SqlClient"/>
[Edit] This is happening because of 'Integrated Security=true' within connection string. If I use sa and password options in connection string it works fine. In my web.config an impersonation context is already defined which works fine outside Task but inside Task it seems the impersonation context is not available, causing EF not to connect.