Data Access has been discontinued. Please refer to this page for more information.

Creating a New Context For Each CRUD Operation

Another approach is to execute CRUD operations by creating and disposing the context whenever that is needed.

For example:

public partial class _Default : System.Web.UI.Page
{
   protected void Page_Load( object sender, EventArgs e )
   {
       using ( FluentModel dbContext = new FluentModel() )
       {
           List<Category> categories = dbContext.Categories.ToList();
       }
   }
}
Public Class _Default
    Inherits Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Using dbContext As New FluentModel()
            Dim categories As List(Of Category) = dbContext.Categories.ToList()
        End Using
    End Sub
End Class