简体   繁体   中英

How do I can to resolve this error?

Using Entity Framework in C#, I get this error:

The entry 'AlMizanEntities' has already been added. (D:\\Document\\Almizan\\AlMizan\\C#\\AlMizan\\bin\\Debug\\AlMizan.vshost.exe.config line 7)

My code:

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

取出line 7D:\\Document\\Almizan\\AlMizan\\C#\\AlMizan\\App.config或删除重复的行其他地方在该文件中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM