指定的命名连接或者未在配置中发现,不打算与EntityClient提供者,或不是有效的使用 [英] The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid
问题描述
我有一个解决方案两个项目。
I have two projects in a solution.
- PizzaSoftware.Data li>
- PizzaSoftware.UI
在数据项目中,我有一个连接到我的数据库我的实体框架模型。
In the Data project, I have my Entity Framework model which connects to my database.
我的UI项目有一个项目引用的数据,这里是它的样子:
My UI project has a project reference to Data and here's how it looks like:
我创建的用户控件文件夹的用户控件。
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="
Data Source=.\SQLEXPRESS;
Initial Catalog=SaharaPizza;
Integrated Security=True;
MultipleActiveResultSets=True
""
providerName="System.Data.EntityClient"
/>
什么可能会造成这个错误?
What could be causing this error?
推荐答案
在你的app.config,您的连接字符串的样子。
In your app.config, your connection string look like..
connection string="
Data Source=.\SQLEXPRESS;
Initial Catalog=SaharaPizza;
Integrated Security=True;
MultipleActiveResultSets=True
"
注意和放大器; QUOT。尝试改变,要一个单引号
Notice the ". Try changing that to a single quote '
这篇关于指定的命名连接或者未在配置中发现,不打算与EntityClient提供者,或不是有效的使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!