Answered by:
error 0019: The EntityContainer name must be unique. An EntityContainer with the name 'AAA' is already defined.

Question
-
I have a solution file where there are multiple projects.
I have a class project called UserManager, and has an EF Model named WebSecurity.edmx
I then have a Web Application project called XXX, and it has another EF Model named AAA.edmx. This project references the UserManager.
The solution complies fine. However, when I run the project, I get the error message
App_Code.AAA.csdl(3,4) : error 0019: The EntityContainer name must be unique. An EntityContainer with the name 'AAAEntities' is already defined.
I don't understand why I am getting this message. There is only one EntityContainer with the name AAAEntities. Can someone help.
Thursday, March 22, 2012 1:57 PM
Answers
-
I struggled with this problem for a while, so I thought I would compile all the suggested solutions into one place:
1. http://stackoverflow.com/questions/6807696/entity-framework-already-defined
2. Work around - http://stackoverflow.com/questions/979664/entity-framework-error-the-entitycontainer-name-must-be-unique
3. My solution - http://p2p.wrox.com/asp-net-4-general-discussion/81694-having-problems-entity-framework.html
My solution was to alter the connection string to include the assembly name, e.g.
<add name="MyEntities"
connectionString="metadata=res://*/App_Code.AAA.csdl|res://*/App_Code.AAA.ssdl|res://*/App_Code.AAA.msl;provider=System.Data.SqlClient;provider connection string="data source=XXX;initial catalog=XXX;user id=XXX;password=XXX;multipleactiveresultsets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
Was changed to (where MyProject is the project assembly name):
<add name="MyEntities"
connectionString="metadata=res://MyProject/App_Code.AAA.csdl|res://MyProject/App_Code.AAA.ssdl|res://MyProject/App_Code.AAA.msl;provider=System.Data.SqlClient;provider connection string="data source=XXX;initial catalog=XXX;user id=XXX;password=XXX;multipleactiveresultsets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
Friday, March 23, 2012 10:07 AM
All replies
-
I struggled with this problem for a while, so I thought I would compile all the suggested solutions into one place:
1. http://stackoverflow.com/questions/6807696/entity-framework-already-defined
2. Work around - http://stackoverflow.com/questions/979664/entity-framework-error-the-entitycontainer-name-must-be-unique
3. My solution - http://p2p.wrox.com/asp-net-4-general-discussion/81694-having-problems-entity-framework.html
My solution was to alter the connection string to include the assembly name, e.g.
<add name="MyEntities"
connectionString="metadata=res://*/App_Code.AAA.csdl|res://*/App_Code.AAA.ssdl|res://*/App_Code.AAA.msl;provider=System.Data.SqlClient;provider connection string="data source=XXX;initial catalog=XXX;user id=XXX;password=XXX;multipleactiveresultsets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
Was changed to (where MyProject is the project assembly name):
<add name="MyEntities"
connectionString="metadata=res://MyProject/App_Code.AAA.csdl|res://MyProject/App_Code.AAA.ssdl|res://MyProject/App_Code.AAA.msl;provider=System.Data.SqlClient;provider connection string="data source=XXX;initial catalog=XXX;user id=XXX;password=XXX;multipleactiveresultsets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
Friday, March 23, 2012 10:07 AM -
Hi Jagdip,
Thanks for sharing your experience here.
Have a nice day.
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Monday, March 26, 2012 8:34 AM -
I had a similar problem.
I had created several EF Models while playing around in a solution and deleted them at various times.
My Entity Container Name was originally named something like MyEntities but had ended up as MyEntities3.
When I tried to rename it MyEntities it said the container name was already in use (when it wasn't).
What fixed it for me was finding the connection string named MyEntities in app.config, temporarily delete that connection string, rename the Entity Container Name to MyEntities, save & build the project and then paste the connection string back into app.config.
Friday, November 28, 2014 4:26 PM