Entity Framework error - “The EntityContainer name must be unique”

前端 未结 10 2287
南旧
南旧 2021-02-07 09:24

We have a solution which consists of two projects - a console application project and a web application project. Each of these has an identical in schema, but differently named

10条回答
  •  孤独总比滥情好
    2021-02-07 09:45

    I fixed this issue in EntityFramework 6.0 by.

    1. During creation of the models, I name the .edmx to the name of the entities. i.e. (MYDbEntities)

    2. After creation i open the MYDbEntities.Context.cs and modified the "Entities" Class to "MYDbEntities".

    3. Open the App.Config and look for the connection string
    4. Open the MYDbEntities.Context.cs and change the connection string to Connection string from the config. example "MyDbConnection"
    5. Make sure that the connection string is like this

      metadata=res:///MYDbEntities.csdl|res:///MYDbEntities.ssdl|res://*/MYDbEntities.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=YourDb;persist security info=True;user id=sa;password=Sw0rdf!sh;multipleactiveresultsets=True;application name=EntityFramework"

    Note: my entities resides in a separate DLL.

    Hope this helps.

提交回复
热议问题