1

I get the following error when I run my site:

Unable to load the specified metadata resource.

Here is my connection string:

 <add name="Context" connectionString="metadata=res://*/database.csdl|res://*/database.ssdl|res://*/database.msl;provider=System.Data.SqlClient;provider connection string=&quot;Server=127.0.0.1,2014;Database=myDbName;User Id=sa;Password=myPassword;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />

After I looking for a solution I found some answers that doesn't help me to solve this problem, because they say I should apply some changes on .edmx file but I don't have any .edmx file in my project.

My project is code-first and as far as I know code-first project's doesn't have any .edmx file.

I also check related firewall port on server and it's okay.

Here are some solutions that I can't use these to solve this problem:

entity framework Unable to load the specified metadata resource [duplicate]

MetadataException Unable to load the specified metadata resource

Unable to load the specified metadata resource. Scripts != Models

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

I use VS17, EF 6.2 and here is my solution structure:

-- myPrj.web
-- myPrj.Model
-- myPrj.Repository
-- myPrj.Service
user3748973
  • 449
  • 2
  • 8
  • 24

1 Answers1

1

Your connection string is for a database first context. For code first, you should use a simpler version, which contains only the information to connect to the database (metadata are created dynamically). For your case, try with this:

<add name="Context" connectionString="Server=127.0.0.1,2014;Database=myDbName;User Id=sa;Password=myPassword;multipleactiveresultsets=True;application name=EntityFramework" providerName="System.Data.SqlClient" />
Najkin
  • 932
  • 1
  • 7
  • 16