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 919621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:34:35+00:00 2026-05-15T18:34:35+00:00

I have recently begun to use the EF v4 Code Only library for some

  • 0

I have recently begun to use the EF v4 Code Only library for some projects I am working on. However, I have run into a bit of a snag. I can’t seem to figure out the proper format for the connection string. I have used the following code to build the connection string:

string connectionString = new EntityConnectionStringBuilder
{
    Provider = "System.Data.SqlClient",
    ProviderConnectionString = new SqlConnectionStringBuilder
    {
        DataSource = "localhost",
        InitialCatalog = "ASM_Testing",
        IntegratedSecurity = true,
        Pooling = false
    }.ConnectionString
}.ConnectionString;

However, using it results in the following error:

Specifications_for_EntityContext.When_logging_in_application_with_valid_app_role_and_password.Login_should_be_successful : System.ArgumentException : Some required information is missing from the connection string. The 'metadata' keyword is always required.
Stack Trace:
   at System.Data.EntityClient.EntityConnection.ValidateValueForTheKeyword(DbConnectionOptions effectiveConnectionOptions, String keywordName)
   at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
   at System.Data.Objects.ObjectContext..ctor(String connectionString)
   at ASM.Data.EntityContext..ctor(String connectionString) in C:\Users\Jon Rista\TFS\Advanced Service Management\Trunk\Main\Source\ASM.Data\EntityContext.cs:line 16
   at Specifications_for_EntityContext.Behaves_like_EntityContext_connected_to_a_database.TestableEntityContext..ctor(String connectionString) in C:\Users\Jon Rista\TFS\Advanced Service Management\Trunk\Main\Source\Tests.ASM.Data\EntityContextFacts.cs:line 165
   at Specifications_for_EntityContext.Behaves_like_EntityContext_connected_to_a_database.InitializeContext() in C:\Users\Jon Rista\TFS\Advanced Service Management\Trunk\Main\Source\Tests.ASM.Data\EntityContextFacts.cs`e`enter code here`nter code here`:line 160
   at ASM.Testing.xUnit.ObservationCommand.Execute(Object testClass) in C:\Users\Jon Rista\TFS\Advanced Service Management\Trunk\Main\Source\ASM.Testing.xUnit\ObservationCommand.cs:line 24
   at Xunit.Sdk.FixtureCommand.Execute(Object testClass)
   at Xunit.Sdk.BeforeAfterCommand.Execute(Object testClass)
   at Xunit.Sdk.LifetimeCommand.Execute(Object testClass)
   at Xunit.Sdk.TimedCommand.Execute(Object testClass)
   at Xunit.Sdk.ExceptionAndOutputCaptureCommand.Execute(Object testClass)

Seeing as I don’t have any metadata…since I am using Code Only, I’m in a bit of a bind. Any insight is greatly appreciated.

The connection string generated by the builder classes is as follows:

provider=System.Data.SqlClient;provider
connection string=”Data
Source=localhost;Initial
Catalog=ASM_Testing;Integrated
Security=True;Pooling=False”


Working Example (based on accepted answers)

It is necessary to use the ContextBuilder to create any instance of a context that uses a code-only mode. Here is a working example of this for those who are searching for an answer to the same problem:

protected override void InitializeContext()
{
    string connectionString = new SqlConnectionStringBuilder
    {
        DataSource = "localhost",
        InitialCatalog = "Testing",
        IntegratedSecurity = true,
        Pooling = false
    }.ConnectionString;

    var connection = new SqlConnection(connectionString);
    var builder = new ContextBuilder<TestableEntityContext>();
    m_context = builder.Create(connection);
}
  • 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-15T18:34:36+00:00Added an answer on May 15, 2026 at 6:34 pm

    To use it:

    var builder = new ContextBuilder<YourContext>();
    
    using (YourContext context = builder.Create(new SqlConnection(ConfigurationManager.ConnectionStrings["yourConenctionKeyInWebConfig"].ConnectionString)))
    {
         ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.