开发者

EF4 error: Unable to load the specified metadata resource

开发者 https://www.devze.com 2023-01-21 19:30 出处:网络
I have just deployed my ASP.NET MVC 2 application using EF 4 and I am getting the following error: Unable to load the specified metadata resource.

I have just deployed my ASP.NET MVC 2 application using EF 4 and I am getting the following error:

Unable to load the specified metadata resource.

On my local machine it runs fine with no errors. This error only comes now when I deployed to the server. I have my enity data model file in MyProject.EntityModel. I used the POCO entity generator to separate my context and entities. These 2 are in another project called开发者_Python百科 MyProject.Entities. I have the connection strings in the app.config in the 2 projects exactly the same. The connection string in the web.config in my MVC app is also the same. I'm not sure why this is giving me issues? I'm also running the app in IIS (that comes with Windows 7) and it works fine. The IIS version on the server is 6 (I think). Here is the full error message:

InnerException
Message: Unable to load the specified metadata resource.
Source: System.Data.Entity
StackTrace: at System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource.LoadResources(String assemblyName, String resourceName, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)
at System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource.CreateResourceLoader(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)
at System.Data.Metadata.Edm.MetadataArtifactLoader.Create(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)
at System.Data.Metadata.Edm.MetadataCache.SplitPaths(String paths)
at System.Data.Common.Utils.Memoizer`2.<>c__DisplayClass2.<Evaluate>b__0()
at System.Data.Common.Utils.Memoizer`2.Result.GetValue()
at System.Data.Common.Utils.Memoizer`2.Evaluate(TArg arg)
at System.Data.EntityClient.EntityConnection.GetMetadataWorkspace(Boolean initializeAllCollections)
at System.Data.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection()
at System.Data.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor)
at MyProject.HolsboerBFGA.Entities.HolsboerBFGAEntities..ctor()
at MyProject.HolsboerBFGA.WebMVC2.Controllers.HomeController..ctor()

Any advice would be appreciated.

Thanks.


I found the solution because i had this same problem. I had this problem because moved my .edmx to another folder and i had to change the namespace so when i run my project appear this error.

I resolved my problem by changing my connection string, adding the namespace "Model" (folder name) to each of the 3 places where the folder changed.

    <add name="connectionName" connectionString="metadata=res://*/Model.MyModel.csdl|res://*/Model.MyModel.ssdl|res://*/Model.MyModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=server;initial catalog=myDataBase;user id=us;password=***;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />


Take a look at this question, the problem seems to be the same.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号