16 c# entity-framework visual-studio-2010 windows-forms-designer
我在解决方案中有两个项目.
在Data项目中,我有我的Entity Framework模型,它连接到我的数据库.
我的UI项目有一个Data的项目引用,这里是它的样子:

我在UserControls文件夹中创建了一个用户控件.
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;
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试将此用户控件拖到设计窗格中时,我收到问题标题中的错误.
这是我的连接字符串的样子:
<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"
/>
Run Code Online (Sandbox Code Playgroud)
可能导致此错误的原因是什么?
小智 19
<connectionStrings>从PizzaSoftware.Data将App.Config从PizzaSoftware.Data 复制到web.config并添加到web.config
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</assemblies>
Run Code Online (Sandbox Code Playgroud)
Rya*_*ord 10
在您的app.config中,您的连接字符串看起来像..
connection string="
Data Source=.\SQLEXPRESS;
Initial Catalog=SaharaPizza;
Integrated Security=True;
MultipleActiveResultSets=True
"
Run Code Online (Sandbox Code Playgroud)
请注意".尝试将其更改为单引号'
| 归档时间: |
|
| 查看次数: |
45329 次 |
| 最近记录: |