Ok I have a new project I am working on that is using .mdf files and LINQ to SQL. Now the issue is this. I am using multiple mdf files and it seems that if i make an update to the database and save it then close and dispose of the database object and open a new connection, LINQ appears to be leaving that file attached as I can't reopen it afterwords without restarting my application.
I have a class that has a property that returns the datacontext object and i have implemented IDisposable and here is my dispose method. Me.Database is the DataContext object.
This method appears to be disposing of the database object properly but it is not allow me to reconnect to the database until i close and reopen my application.Code:' IDisposable Protected Overridable Sub Dispose(ByVal disposing As Boolean) If Not Me.disposedValue Then If disposing Then 'Check to see if the database object exists If Not Me.DataBase Is Nothing Then 'If connection is open then close it If Me.DataBase.Connection.State = ConnectionState.Open Then 'Close the connection Me.DataBase.Connection.Close() End If 'Dispose of the connection Me.DataBase.Connection.Dispose() 'Dispose of the database object Me.DataBase.Dispose() End If End If End If Me.disposedValue = True End Sub
Any help is appreciated.




Reply With Quote

