score:16

If table C and D contain a lot of rows, it may just be taking longer to run the insert than the default command timeout (30 seconds). Add this line before your insert command:

context.CommandTimeout = 240  // set timeout to 4 minutes

By the way, you should be disposing of the context when you have finished with it. The easiest way to do this is:

using (Datacontext context = new Datacontext())
{
    // your code goes here
}

Related Articles