Errors 11 and 2002: "The EntityContainer ... does not exist in MetadataWorkspace"
Solution 1
Sounds like there is either a problem with your configuration or that one of the entity framework files is corrupt.
Fastest way to fix it is probably to delete the model, make sure all references to it in the configuration files are deleted, then regenerate the model from the database.
Solution 2
Just my cent for this error:
Working on Oracle db schema I modified a size of primary key field on a table. This field is foreign key on another table. I forgot to modify the size for this second table.
In my .Net web project with Entity Framework 5.0 I regenerate the model from database... ERROR 2002 The EntityContainer bla... bla...
I spent a lot of time with this... silly mistake and the more silly information coming from ODT 12.
Solution 3
The .edmx
format can be very confusing to troubleshoot. In your case, it may be a case of two names not matching up.
Open the .edmx
file using the XML editor, and toggle all outlining and you should be able to see 3 sections.
SSDL
andCSDL
andC-S
mapping.
The SSDL
Storage corresponds to your database tables. The CSDL
Conceptual corresponds to your DbSets
or ObjectSets
. The C-S
mapping is how each of the conceptual sets relate to the storage sets.
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
<!-- EF Runtime content -->
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="SamDb.Store" Alias="Self" Provider="System.Data.SqlClient"...
<EntityContainer Name="SamDbStoreContainer">
</edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="SamDb" Alias="Self" ...>
<EntityContainer Name="SamDbContainer" ...>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
<EntityContainerMapping
StorageEntityContainer="SamDbStoreContainer"
CdmEntityContainer="SamDbContainer" ...>
</edmx:Runtime>
</edmx:Edmx>
To resolve the issue, you must make sure the StorageEntityContainer
and the CdmEntityContainer
names match up in the C-S space. In the sample above it is the SamDbStoreContainer
and SamDbContainer
Solution 4
(Late, I know, but this question gets lots of views)
I bet you renamed your class somewhere. Visual studio doesn't propagate those changes to the xml file. In the edmx xml, look for the <EntityContainerMapping CdmEntityContainer="badEntity" />
tag, and replace badEntity
with the correct name, in your case BancorLineEntidades
Also related - http://mvcmusicstore.codeplex.com/discussions/220395
Solution 5
For me, I had a similar error:
Schema specified is not valid. Errors: \r\nEntities.MyModel.msl(203,12) : error 2009: Content not valid. The conceptual side Member or Property 'Unit' specified as part of this MSL does not exist in MetadataWorkspace.
Where I had my UNIT in both:
<EntityTypeMapping TypeName="IsTypeOf(MyObjectCharacteristic)">
<MappingFragment StoreEntitySet="OBJECT_CHARACTERISTICS">
<ScalarProperty Name="Unit" ColumnName="UNIT" />
<ScalarProperty Name="ClassName" ColumnName="CLASSNAME" />
<ScalarProperty Name="MyObjectID" ColumnName="OBJECTID" />
</MappingFragment>
</EntityTypeMapping>
<EntitySet Name="OBJECT_CHARACTERISTICS" EntityType="Self.OBJECT_CHARACTERISTICS" store:Type="Views" store:Schema="DBA">
<DefiningQuery>SELECT
dbo.RESOURCE.OBJECTID,
dbo.RESOURCE.CLASSNAME,
dbo.RESOURCE.UNIT
FROM dbo.RESOURCE
</DefiningQuery>
</EntitySet>
Also, I had to ensure that the associated class entity details for the object that represented the database table had the UNIT data member:
<EntitySetMapping Name="ObjectCharacteristics">
<EntityTypeMapping TypeName="IsTypeOf(ObjectCharacteristic)">
<ScalarProperty Name="Unit" ColumnName="UNIT" />
<ScalarProperty Name="ClassName" ColumnName="CLASSNAME" />
<ScalarProperty Name="ObjectId" ColumnName="OBJECTID" />
</EntityTypeMapping>
</EntitySetMapping>
And also,
<EntityType Name="ObjectCharacteristic" A:TypeAccess="Public" xmlns:a=""http://schemas.microsoft.com/ado/2006/04/codegeneration">
<Key>
<PropertyRef Name="ObjectId" />
</Key>
<Property Name="ObjectId" Type="String" />
<Property Name="ClassName" Type="String" />
<Property Name="Unit" Type="String" />
</EntityType>
Cleiton
Filho de mestiços, pobre brasileiro procurando um lugar para trabalhar e viver. I'm not a native speaker of English, so if you find any mistakes in what I've written, feel free to correct or edit them for me.
Updated on June 13, 2022Comments
-
Cleiton almost 2 years
I'm getting the following error when I try to compile my web application:
Error 11 Error 2002: The EntityContainer 'SomeEntitieContainerName' for the conceptual model specified as part of this MSL does not exist in MetadataWorkspace.
I have only a
*.edmx
named BancorlineDB.edmx that has an "Entity Container Name" set to "BancorLineEntidades". -
Chlebta about 10 yearsHow to do that, because I tried to delete my Model and re-creat it but always same problem. Also i tried on new project but same error
-
SomeCode.NET over 8 years@Chlebta How did you solve your problem please? I have the same, and deleting the model ana generating it again doesn't solve the issue :(
-
Chlebta over 8 years@Younes sorry I can't remember any more