The EntityContainer name must be unique. An EntityContainer with the name 'Entities' is already defined

前端 未结 12 970
孤城傲影
孤城傲影 2020-12-15 03:11

For a little background:

I have a DLL project with the following structure:

Rivworks.Model (project)  
  \\Negotiation (folder)  
      Model.edmx          


        
相关标签:
12条回答
  • 2020-12-15 03:16

    If you are using web deployment from Visual Studio sometimes doesn't delete the old dlls. I had the same problem, change to Web Deployment Package and didn't give me problems.

    0 讨论(0)
  • 2020-12-15 03:18

    In my case, the problem was caused by my connection string in Web.config being named the same thing as my entities container class.

    Change

    <add name="ConflictingNameEntities" connectionString="metadata=res://*/blahblah
    

    to

    <add name="ConflictingNameEntitiesConnection" connectionString="metadata=res://*/blahblah
    

    and regenerate the container class by right-clicking ConflictingNameModel.Context.tt in Solution Explorer and clicking "Run Custom Tool".

    0 讨论(0)
  • 2020-12-15 03:18

    In my case, probably after merging a version back, my startup project file (csproj) got corrupted.

    Al the Entity classes where added:

    <Compile Include="Class.cs">
      <DependentUpon>MyModel.tt</DependentUpon>
    </Compile>
    

    After removing all relevant entries by hand the problem was solved.

    0 讨论(0)
  • 2020-12-15 03:20

    Your two EDMX files probably have the same entity container name. You need to change (at least) one of them.

    In the GUI designer, open Model Browser. Look for a node that says "EntityContainer: Entities". Click it. In Properties, change Name to something else. Save and rebuild.

    0 讨论(0)
  • 2020-12-15 03:23

    I had a same problem in my asp.net website, to resolve the problem I purposely added compile time error in one of the cs file in the app code by removing a semicolon, then I rectified the compilation problem by adding semicolon again.

    This process caused application to compile again.After this error got vanished.

    0 讨论(0)
  • 2020-12-15 03:25

    Hijacking this, since it is the top Google result for the error message.

    In case anyone else encounters this while only using a single model/context: I once ran into this problem because the assembly containing the model/context was renamed and a copy with the previous name remained in the bin directory of the application. The solution was to delete the old assembly file.

    0 讨论(0)
提交回复
热议问题