Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 676497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:56:04+00:00 2026-05-14T00:56:04+00:00

I just created a user control. This control also makes use of my static

  • 0

I just created a user control.
This control also makes use of my static Entity Framework class to load two comboboxes.
All is well and runs without a problem. Design and runtime are working.
Then when I stop the application all the forms that contain my UserControl don’t work any more in design time. I just see two errors:

Error1:
The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

Error 2:
The variable ccArtikelVelden is either undeclared or was never assigned.
(ccArtikelVelde is my UserControl)

Runtime everything is still working

My static EF Repositoy class:

public class BSManagerData
{
    private static BSManagerEntities _entities;
    public static BSManagerEntities Entities
    {
        get
        {
            if (_entities == null)
                _entities = new BSManagerEntities();
            return _entities;
        }
        set
        {
            _entities = value;
        }
    }
}

Some logic happening in my UserControl to load the data in the comboboxes:

private void LaadCbx()
{
    cbxCategorie.DataSource = (from c in BSManagerData.Entities.Categories
                               select c).ToList();
    cbxCategorie.DisplayMember = "Naam";
    cbxCategorie.ValueMember = "Id";
}

private void cbxCategorie_SelectedIndexChanged(object sender, EventArgs e)
{
    cbxFabrikant.DataSource = from f in BSManagerData.Entities.Fabrikants
                              where f.Categorie.Id == ((Categorie)cbxCategorie.SelectedItem).Id
                              select f;
    cbxFabrikant.DisplayMember = "Naam";
    cbxFabrikant.ValueMember = "Id";
}

The only way to make my forms work again, design time, is to comment out the EF part in the UserControl (see above) and rebuild.
It’s very strange, everything is in the same assembly, same namespace (for the sake of simplicity).

Anyone an idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:56:04+00:00Added an answer on May 14, 2026 at 12:56 am

    Looks like you’re somehow executing database code in design mode. To prevent this, hunt down the control and method causing this, and use:

    if (DesignMode)
        return
    

    Also, it’s a very bad idea to cache the database context statically. It will cause problems with multithreading, and also when you’re doing inserts and deletes. The database context is meant to be used for a single “unit of work”, is adding 2, and removing 3 other objects and calling SaveChanges once.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a weird problem. I have created Web User Control with two TextBoxes
i have just created a drum app. The user taps on the individual buttons
Just created an acc on SO to ask this :) Assuming this simplified example:
I just created a project so my Solution Explorer looks like this: (source: kalleload.net
I have created a WinForms user control that is a set of five cascading
Maybe someone can help me out. I have created a simple web user control,
Just created a WSS site with a some custom web-parts. But I get an
I just created a ASP.NET MVC project in VS2008. When I press F5 to
I just created a ASP.NET MVC project and was able to build and browse
I just created a new table and filled it with data. When I run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.