Entity Framework manages connections by itself. In other words, you as a developer need not open and close connections manually. However, there are scenarios where you would want to manage the opening and closing of connections manually. Saving large-sized files to a database is one such scenario.
In this recipe, we will look at the steps required in managing connections manually. To do so, we will use the application developed in the previous recipe.
FileUpload.slnin Visual Studio 2012.
UploadForm.csin the view code mode.
btnUpload_Clickmethod, replace the
usingstatement with the following statement:
CookBookEntities context = new CookBookEntities();