Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6045559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:08:17+00:00 2026-05-23T07:08:17+00:00

I have a solution with two relevant projects. The first builds My.exe , and

  • 0

I have a solution with two relevant projects. The first builds My.exe, and the second builds a class library MyModel.dll that contains only my EF model.

I’m getting a MetadataException in my Model’s VS-generated ObjectContext ctor. I’ve read through Troubleshooting Entity Framework Connection Strings, but I still haven’t been able to narrow down my problem.

The offending constructor code:

public MyEntities() :
    base(@"name=MyEntities", "MyEntities") // MetadataException here
{
    this.ContextOptions.LazyLoadingEnabled = true;
    OnContextCreated();
}

Metadata Artifact Processing is set to EmbedInOutputAssembly. When I open MyModel.dll in Reflector, I see:

  • DataAccessLayer.MyModel.csdl
  • DataAccessLayer.MyModel.msl
  • DataAccessLayer.MyModel.ssdl

I’ve tried setting Build Action for my app.config to None and Content, and neither makes a difference. The config file contains:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
    <add name="MyEntities" 
         connectionString="metadata=
            res://*/DataAccessLayer.MyModel.csdl|
            res://*/DataAccessLayer.MyModel.ssdl|
            res://*/DataAccessLayer.MyModel.msl;
            provider=Devart.Data.PostgreSql;
            provider connection string=&quot;
                User Id=MY_USER;
                Password=MY_PASS;
                Host=127.0.0.1;
                Database=MY_DB;
                Persist Security Info=True&quot;"
         providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>

I’ve tried replacing the resource prefix res://*/ with both res://MyModel.dll/ and res://MyModel/, leaving the rest intact (because it matches the resources in MyModel.dll), but neither solved the problem. My class library is strong-named.

Both my executable and class library projects contain references to System.Data.Entity and Devart.Data.PostgreSql, and My.dll is being built to the same location as My.exe.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:08:18+00:00Added an answer on May 23, 2026 at 7:08 am

    I stepped into .NET source code, and by examining the arguments & local variables of internal EF calls, found the resource assembly name was still set to *.

    It turns out a bug in my application code set the model’s default connection string before calling the ObjectContext ctor. It was pulled from a Settings.settings file, which hadn’t been recently sync’d with the latest, correct app.config.

    Some reflections on our discussion in the comments:

    • The correct assembly name in app.config is MyModel rather than MyModel.dll (as shown in Craig’s article.) Using MyModel.dll produces an exception in the EF code.

    • Calling the ctor as base(@"name=MyEntities") instead of base(@"name=MyEntities", "MyEntities") actually produced a new exception in ObjectContext.GetEntitySetName()

    I updated Settings.settings to be in sync with app.config, and everything is now working.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an solution in VS 2008 which contains two class library projects and
In Visual C# 2008, I have a solution with two projects. First project contains
I have a solution that contains two projects. One project is an ASP.NET Web
I have two WIN32 DLL projects in the solution, main.dll should call a function
I have a solution with two relevant (to this question) projects, and a few
I have a solution with two projects. One for project for the production code
I have a Visual Studio 2008 solution with two projects (a Word-Template project and
I have a Solution with several projects in it, including two asp.net mvc projects
I'm working on a solution in Visual Studio 2010 Ultimate that contains two C#
I have two arrays, the first one is a (n, 2) array which contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.