在C#中使用實體框架,我得到這個錯誤:我該如何解決這個錯誤?
The entry 'AlMizanEntities' has already been added. (D:\Document\Almizan\AlMizan\C#\AlMizan\bin\Debug\AlMizan.vshost.exe.config line 7)
我的代碼:
private void Fraz()
{
label1.Text = "Fraz ...";
Application.DoEvents();
AlMizanEntities1 ObjAE = new AlMizanEntities1();
}
public partial class AlMizanEntities1 : ObjectContext
{
/// <summary>
/// Initializes a new AlMizanEntities1 object using the connection string found in the 'AlMizanEntities1' section of the application configuration file.
/// </summary>
// *ERROR* occurs here
public AlMizanEntities1() : base("name=AlMizanEntities1", "AlMizanEntities1")
{
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}
/// <summary>
/// Initialize a new AlMizanEntities1 object.
/// </summary>
public AlMizanEntities1(string connectionString) : base(connectionString, "AlMizanEntities1")
{
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}
/// <summary>
/// Initialize a new AlMizanEntities1 object.
/// </summary>
public AlMizanEntities1(EntityConnection connection) : base(connection, "AlMizanEntities1")
{
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}
}
你需要顯示一些代碼和模式。它看起來像是違反了一個獨特的約束,但不可能用更多的信息來說明。除了前面提到的你應該提供一些關於表格輸入和內容的信息。不是所有這些都足以重現您的問題 –