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

  • Home
  • SEARCH
  • 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 1097349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:25:11+00:00 2026-05-17T00:25:11+00:00

I am using C#, Visual Studio 2010 and Entity Framework 4. I have an

  • 0

I am using C#, Visual Studio 2010 and Entity Framework 4. I have an assembly that contains multiple entity models. Project requirements are such that I am not storing any connection information in the app.config.

I have written a method that returns an entity connection string when I supply the name of the model I wish to load.

public static string GetEntityConnectionString(string modelName)
{
    const string providerName = "somedatabaseprovider";
    string metadata = string.Format(@"res://*/{0}.csdl|res://*/{0}.ssdl|res://*/{0}.msl", modelName);

    EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder
    {
        Provider = providerName,
        ProviderConnectionString = GetProviderConnectionString(),
        Metadata = metadata
    };

    return entityBuilder.ToString();
}

I now want to make it a little more bullet-proof by passing the entity model type, instead of a literal string for the model name. When I am editing the entity model in Visual Studio, the Properties window for MyModel (of type ConceptualEntityModel) contains a property called ‘Entity Container Name’ that shows MyEntities, and another property called ‘Namespace’ which shows MyModel.

At design-time, the type that I have access to is MyEntities. How can I derive the value stored in the ‘Namespace’ property of the ConceptualEntityModel at run-time?

  • 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-17T00:25:12+00:00Added an answer on May 17, 2026 at 12:25 am

    Well, if your goal is to make this “bulletproof,” this won’t work. The string you call modelName is not actually the model name, but the resource name. In your case it coincidently happens to be the same as the model name, but that isn’t always true.

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

Sidebar

Related Questions

I have a MVC 2 project, using Entity Framework, in Visual Studio 2010 and
My scenario I'm using Visual Studio 2010 with Entity Framework 4.1 I have a
I've created a web application project in Visual Studio 2010 using Entity Framework Code
I'm using Visual Studio 2010 RTM with .NET/Entity Framework 4 RTM with a model
I am using Entity framework with following tools: MS Visual studio 2010 Professional SP1
I am using Entity Framework, C# 4.0 and Visual Studio 2010. I need to
I'm using Entity Framework in Visual Studio 2010 Beta 2 (.NET framework 4.0 Beta
To begin with: Using Entity Framework v4.0. ASP.NET MVC 2.0. Visual Studio 2010. I
Using Visual Studio 2010 I created an Office 2010 Word add-in project that has
I have Visual Studio 2010 on Windows 7. My project is using the .net

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.