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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:25:07+00:00 2026-05-22T20:25:07+00:00

How would I create an EntityConnection string for an SqlServerCe database? I tried following

  • 0

How would I create an EntityConnection string for an SqlServerCe database?

I tried following the MSDN Example on How to: Build an EntityConnection Connection String

const string PROVIDER = "System.Data.SqlClient";

static string BuildEntityConnString(string dbFileName, string password) {
  // dbFileName is filename without the extension
  SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder();
  sqlBuilder.DataSource = PROVIDER;
  sqlBuilder.InitialCatalog = dbFileName;
  sqlBuilder.IntegratedSecurity = true;
  sqlBuilder.Password = password;
  string providerString = sqlBuilder.ToString();
  EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder();
  entityBuilder.Provider = PROVIDER;
  entityBuilder.ProviderConnectionString = providerString 
  entityBuilder.Metadata = string.Format(@"res://*/{0}.csdl|res://*/{0}.ssdl|res://*/{0}.msl", dbFileName);
  string connString = entityBuilder.ToString();
  using (EntityConnection con = new EntityConnection(connString)) {
    con.Open();
    Console.WriteLine("{0} Entity String created.", dbFileName);
    con.Close();
  }
  return connString;
}

However, but it throws an error:

A network-related or instance-specific error occurred while establishing a 
connection to SQL Server. The server was not found or was not accessible. Verify 
that the instance name is correct and that SQL Server is configured to allow 
remote connections. (provider: Named Pipes Provider, error: 40 - Could not open 
a connection to SQL Server)

With some searching on here, I was able to find info stating that the MSDN Example returns an SqlClient connection.

However, I was not able to find out how to return an Sql CE Connection.

I tried supplying the EntityConnection the SQL CE Connection String that allows me to open the .SWF database and read it conventionally:

const string PROVIDER = "Microsoft.SqlServerCe.Client.3.5";

static string BuildEntityConnString(string dbFileName, string password) {
  EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder();
  entityBuilder.Provider = PROVIDER;
  entityBuilder.ProviderConnectionString = myCeConnectionString;
  entityBuilder.Metadata = string.Format(@"res://*/{0}.csdl|res://*/{0}.ssdl|res://*/{0}.msl", dbFileName);
  string connString = entityBuilder.ToString();
  using (EntityConnection con = new EntityConnection(connString)) {
    con.Open();
    Console.WriteLine("{0} Entity String created.", dbFileName);
    con.Close();
  }
  return connString;
}

This version throws a different error:

Unable to find the requested .Net Framework Data Provider.
It may not be installed.

What could I be doing wrong?

I found this related SQL Server Fix, but the fix needs to be something I can set in my code so that my project will run on our Customers’ computers at other locations without network administrators.

  • 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-22T20:25:07+00:00Added an answer on May 22, 2026 at 8:25 pm

    You need to register the CE provider in your app.config. Also, AFAIK, “Microsoft.SqlServerCe.Client.3.5” is the pre-release name of the provider; the RTM is “System.Data.SqlServerCe.3.5”.

    Try changing PROVIDER to match the second string, and add this to app.config:

      <system.data>
        <DbProviderFactories>
          <remove invariant="System.Data.SqlServerCe.3.5" />
          <add
            name="Microsoft SQL Server Compact Data Provider"
            invariant="System.Data.SqlServerCe.3.5"
            description=".NET Framework Data Provider for Microsoft SQL Server Compact"
            type="System.Data.SqlServerCe.SqlCeProviderFactory,
              System.Data.SqlServerCe,
              Version=3.5.0.0,
              Culture=neutral,
              PublicKeyToken=89845dcd8080cc91"
          />
        </DbProviderFactories>
      </system.data>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We tried last night to build some code which would create a new public
How does the code looks that would create an object of class: string myClass
How would you create a database in Microsoft Access that is searchable only by
I have tried to create this script that would create 10 empty slides, but
I want to write a c# class that would create a connection to a
I tried where I would create a temporary column using case as join_id but
I'm trying to make a small C++/Lua system where I would create my objects
I normally would create a limited rights user and run the process under that
I'd like to know how one would create an application that starts in the
Versioning If your events changes you would create a new version of that event,

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.