I realise that this has been asked a number of times but I just can\'t seem to get the bottom of my issue. I\'m getting the following error stack:
I actually received this identical error because my Entity Framework
connection string was pointing to a valid database however it was the incorrrect database.
If you have the following instances in SQL Server:
Make sure that the connection string points to the same database that the .EDMX
is wired up to and was generated from. Seems obvious enough, but when copying EF
connection settings from 1 project to another this error was made and the net result was the Unable to load the specified metadata resource
message. Once I used the correct connection string pointing to the correct database and assembly - the error was resolved.
The easiest thing to do is take the original connection string created in the .config
file residing next to the .EDMX
and copy where needed to make sure subtle or minor omissions/mistakes are not made causing EF
to not load/connect correctly.
I hit this issue and it has bit me many, many, many times and I always forget how I fix it.
All I had to do is set the default.aspx as the start page.
Obviously this won't help everyone but in my case I have gone down the road of checking my config, connection string...
Hope this help someone, or at least the next time I google it I will find my fix. :)
Solution :
1) Open .edmx file from visual studio.
2) Click anywhere.
3) Should see edmx property window.
4) Change Namespace to the correct folder name.
5) 1: https://i.stack.imgur.com/6sZvo.png (select image for more details ).
I was getting the same error. My connection string was as following
<add name="EmployeeDbContext" connectionString="metadata=res://*/EmployeeModel.csdl|res://*/EmployeeModel.ssdl|res://*/EmployeeModel.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=Sample;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
I changed it to following and it fixed the problem
<add name="EmployeeDbContext" connectionString="server=.; database=Sample; integrated security=true;"
providerName="System.Data.SqlClient"/>
I want to share my experience on this and how I solved it. In my case it happens because I copy and pasted my connection string on production server. My application was using Entity framework.
Problem was on metadata
I named my entity model as 'BetModel' but on my connection string I was using 'Entity' - 'res:///Entity.csdl|res:///Entity.ssdl|res://*/Entity.msl' on 'metadata' (reason was because i copy pasted it).
So my wrong ConnectionString was:
connectionString="metadata=res://*/Entity.csdl|res://*/Entity.ssdl|res://*/Entity.msl;provider=System.Data.SqlClient;provider connection string="data source=;initial catalog=;persist security info=True;user id=;password=;MultipleActiveResultSets=True;App=EntityFramework""
and the corrected ConnectionString was:
<add name="BetEntities" connectionString="metadata=res://*/BetModel.csdl|res://*/BetModel.ssdl|res://*/BetModel.msl;provider=System.Data.SqlClient;provider connection string="data source=;initial catalog=;persist security info=True;user id=;password=;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
Also, be aware when moving the edmx file from say a web application to a data layer, (web.config - connection / app.config - connection) that you change the connectionstring in the data layer AND the webservice layer. (else one uses two different connection strings, and this causes such a problem)