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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:39:02+00:00 2026-05-25T16:39:02+00:00

If I use an app.conf file to define the connection for a SQL CE

  • 0

If I use an app.conf file to define the connection for a SQL CE 4.0 DB, my app works fine.

How can I “initialize the connection” (hope this is the right term…) without an app.conf, in the code?

Here is what I have so far (not much):

SqlCeConnectionStringBuilder builder = new SqlCeConnectionStringBuilder();
builder["Data Source"] = "db.sdf";               

//What is missing here?

PartyDB DB = new PartyDB();

var dinners = from d in DB.Dinners                        
              select d;

Any hint is highly appreciated.

  • 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-25T16:39:03+00:00Added an answer on May 25, 2026 at 4:39 pm

    J. Tihon’s answer helped me. I am adding the following for future reference. I initialized the Database.DefaultConnectionFactory in the constructor.

    public partial class MyDb: DbContext
    {
        public static string Connection
        {
            get
            {
    
                var result = new SqlCeConnectionStringBuilder();
    
                result["Data Source"] = "MyDatabaseFile.sdf";
    
                return result.ToString();
            }
        }
    
        public MyDb()
            : base(Connection)
        {
            Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");
        }
    
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
    
        }
    
        public DbSet<MyTable> MyTable { get; set; }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

You can use App.config; but it only supports key/value pairs. You can use .Net
if your app use this solution , do do you plan port the app
All the examples that I can search online use the App.Config mode of specifying
In our web-app we use PHP5.2.6 + PDO to connect to a SQL Server
I have put a file in my grails-app/conf package called size_config.xml . When the
We use MyCPAN::App::DPAN (Version 1.28) just like in Question: How can I manage Perl
The app runs fine using django internal server however when I use apache +
I created a Play! app and deployed it under TomCat. This works well. The
Tried following the instructions here: How to use Google app engine with my own
IN my app I use a threadpool with a custom ThreadFactory. My code looks

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.