Something wrong with references using two layers in Entity

Asked

Viewed 328 times

1

I made an example in Entity 5.0 and with 1 layer worked perfect.

Now I’ve separated into UI and DAL, but this giving error. The same page that worked in the layer DAL when made in the UI is giving error. I believe it’s some lack of reference.

The mistake is:

Server Error in '/' Application.

Unable to load the specified metadata resource.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.MetadataException: Unable to load the specified metadata resource.

Source Error: 

Line 41:    using (var ctx = new DAL.TracesEntities())
Line 42:    {
Line 43:        var lambda = ctx.Traces.Where(q => q.DataBaseName == "megacorretor" || q.DataBaseName == "stats_mega")
Line 44:                               .GroupBy(a => new { a.TextData, a.DataBaseName })
Line 45:                               .Select(b => new { ...

I referenced the DAL project and the DLL:

packages\EntityFramework.5.0.0\lib\net45\EntityFramework.dll

I can’t remember if I should copy any .tt something for the UI to work. Strange that the interlisense in UI works perfectly with the entity of DAL

  • did you ever change the namespace of the classes moved? If not changed, that’s why Intellisense still recognizes

  • I don’t know the answer, but to avoid this kind of error you could use code first. There is a very simple tool that generates the classes for you and leaves the code cleaner than with edmx, is Entity power tools. Have an example of it on my blog http://devrodrigosantos.wordpress.com/2014/03/12/beginning/

  • Yes I changed the namespace, alias I created a new file in the UI but with the same code.. intelisense 100% works but it does not find the resource! I believe that here all develop with several layers for no one gives this error?

  • There was no way to make Code first the database already exists with 20GB of data.

1 answer

2


This error means that the resource (refers to EDMX) not found. This EDMX file stores the metadata used to map your class model to the database model.

Check your EDMX file designer, the property MetadataArtifactProcessing is set to Embed in Output Assembly... is what makes EDMX turn into a resource.

  • I was already in 'Embed in Output Assembly' also changed the Build Action to 'Embedded Resource' and Copy to output in Always and tb did not work.. continues the error.

  • I went through this problem and the directory of my edmx had the incorrect metada. Thank you For the @Miguel Angelo reply.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.