The supplied named connection is either missing from the settings, not compatible with the EntityClient provider, or invalid.

c# entity-framework visual-studio-2010 windows-forms-designer

Question

I have two projects in a solution.

  1. PizzaSoftware.Data
  2. PizzaSoftware.UI

In the Data project, I have my Entity Framework model which connects to my database.

My UI project has a project reference to Data and here's how it looks like:

enter image description here

I've created a user control in the UserControls folder.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PizzaSoftware.Data;

namespace PizzaSoftware.UI.UserControls
{
    public partial class AutoCompleteTextBox : UserControl
    {
        AutoCompleteStringCollection completeCollection = new AutoCompleteStringCollection();

        public AutoCompleteTextBox()
        {
            InitializeComponent();
        }

        private void AutoCompleteTextBox_Load(object sender, EventArgs e)
        {
            CustomerRepository repo = new CustomerRepository();
            var customers = repo.FindAllCustomers().ToList();

            foreach (var customer in customers)
            {
                completeCollection.Add(customer.Name);
            }

            txtSearchBox.AutoCompleteMode = AutoCompleteMode.Suggest;
            txtSearchBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
            txtSearchBox.AutoCompleteCustomSource = completeCollection;
        }
    }
}

When I try to drag this user control into the design pane, I receive the error in the question title.

Here's what my connection string looks like:

<connectionStrings>
   <add 
      name="SaharaPizzaEntities"
      connectionString="
         metadata=res://*/PizzaSoftwareEntityModel.csdl|res://*/PizzaSoftwareEntityModel.ssdl|res://*/PizzaSoftwareEntityModel.msl;
         provider=System.Data.SqlClient;
         provider connection string=&quot;
            Data Source=.\SQLEXPRESS;
            Initial Catalog=SaharaPizza;
            Integrated Security=True;
            MultipleActiveResultSets=True
         &quot;"
      providerName="System.Data.EntityClient"
/>

What could be causing this error?

1
16
6/24/2013 9:08:38 PM

Accepted Answer

In your app.config, your connection string look like..

   connection string=&quot;
      Data Source=.\SQLEXPRESS;
      Initial Catalog=SaharaPizza;
      Integrated Security=True;
      MultipleActiveResultSets=True
   &quot;

Notice the &quot. Try changing that to a single quote '

10
6/24/2013 9:05:05 PM

Popular Answer

Copy <connectionStrings> from App.Config from PizzaSoftware.Data to web.config from PizzaSoftware.UI and add to web.config

<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</assemblies>


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow