7

I have a 3 tiered project.

1) Project.Data (EDMX file)
2) Project.Model (POCO's)
3) Project.Console (Console app)

I have added the connection string into the Project.Console.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <connectionStrings>
        <add name="ProjectEntities" connectionString="metadata=res://*/Project.csdl|res://*/Project.ssdl|res://*/Project.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=PC\SQLEXPRESS;Initial Catalog=Project;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
    </connectionStrings>
</configuration>

The Project.Model is built using the EntityObject T4 Template in VS2010. It generates a ObjectContext class, with this constructor:

public ProjectEntities() : base("name=ProjectEntities", "ProjectEntities")
{
    this.ContextOptions.LazyLoadingEnabled = true;
    OnContextCreated();
}

I am just trying to instantiate the context object, in the Project.Console:

namespace Project.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            ProjectEntities pe = new ProjectEntities();
        }
    }
}

However, I am getting a MetadataException was unhandled error at the constructor. Stating Unable to load the specified metadata resource.

I have done a ton of research (Googling), and found that it seems to be a linking issue on those resources. I cannot seem to find a resolution.

Any help is appreciated.

2
  • I read the article that Craig suggested, but I am still uncertain where I have to place the ...dll file reference? I have a scenario likes yours. I am assuming in the Project.Model's app.config? I have my context and pocos separated from the edm file in separate project as in your case, Project.Model. Commented Oct 26, 2010 at 12:39
  • In my console project I needed a reference to my data (EDMX) and model project. It also required a reference to System.Data.Entity. Commented Oct 26, 2010 at 13:49

3 Answers 3

8

I wrote a lengthy guide to debugging this error a while back.

Sign up to request clarification or add additional context in comments.

Comments

3

Open your assembly using any resource viewer (e.g., RedGate .NET Reflector) and check that the name of the metadata resource is the same that you have specified in the app.config.

Comments

0

Please replace the * with your project.data assembly like below

<add name="ProjectEntities" connectionString="metadata=res://Project.Data/Project.csdl|res://Project.Data/Project.ssdl|res://Project.Data/Project.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=PC\SQLEXPRESS;Initial Catalog=Project;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.