My project is a Windows Application, targeting .NET Framework 4.5., referencing EntityFramework 6.1.1.
My main form has a UserControl, which has a second usercontrol within. The nested UserControl constructor has something similar to:
public ucNestedUserControl()
{
InitializeComponent();
listAll();
}
listAll
is a method which pulls loads data from SQL Server database tables (using EntityFramework).
I did some minor changes in database (removed delete cascade from some relationships), and after opening my project and double clicking (step 1) the main Windows Form in Solution Explorer, I noticed that Visual Studio is firing the nested UserControl constructor (step 2) and reading the database records with listAll
method.
How can I avoid this nested UserControl constructor from loading/connecting to database while in design mode? Is this Visual Studio 2013 default behavior?