Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialHakim Rachidi
38,490 PointsData base still in use error
After closing all programs and tabs that used the Database I still get the error saying that the Database can not be dropped because it is in use. When I watch the status of the server in sqllocaldb.exe I noticed that the connection is closing but only after some amount of time (5 - 10 min).
Is this normal or did I forget anything. I know I could just close it manually but why even is there a dispose method in the when it is not working properly.
1 Answer
Allan Clark
10,810 Pointsthe Dispose method should rarely be called directly. It is better practice to create the object with a 'using' statement. This will make sure the connection is closed even if the code is stopped or errored out before the Dispose method would be called.
Would need to see code to provide a more precise answer.
Hakim Rachidi
38,490 PointsI am already using a using statement, maybe it's because my VM is a little bit slow. When I call the contexts Dispose method, the method executes but the Database is closing with some delay.
Thanks anyway ;
Damien Bactawar
8,549 PointsDamien Bactawar
8,549 PointsI am experiencing the same problem. Did you find a solution for it?