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

Two of my projects are in a solution.

  1. PizzaSoftware.Data
  2. PizzaSoftware.UI

I have my Entity Framework model connected to my database in the Data project.

Here is how the project reference to Data appears in my UI project:

enter image description here

In the UserControls folder, I've built a user control.

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;
        }
    }
}

I get the problem mentioned in the question's title when I attempt to move this user control into the design pane.

My connection string is shown below:

<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 may be the root of this error?

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

Accepted Answer

Your connection string should appear like this in your app.config.

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

Recall the ". Change it to a single quotation if you can.

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

Popular Answer

ZZZ_tmp


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