使用 C# 中的实体框架, 我明白这个错误 :
The entry AlMizanEntities has already been added. (D:DocumentAlmizanAlMizanC#AlMizaninDebugAlMizan.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();
}
}