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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:15:33+00:00 2026-05-24T09:15:33+00:00

I’m currently working in c# with a SQLite database file (data.db3) which is located

  • 0

I’m currently working in c# with a SQLite database file (data.db3) which is located in the application directory. During development, an absolute path has been used and it worked fine so far. Now I’m trying to access the database by using a relative path, but that fails because of a possibly wrong connection string. The following connection string works fine and was automatically created by the ADO.Net framework.

<connectionStrings>
<add name="dataEntities" 
 connectionString="metadata=res://*/DataEntities.csdl|res://*/DataEntities.ssdl|res://*/DataEntities.msl;provider=System.Data.SQLite;provider connection string='data source=&quot;C:\Projekte\DataProvider\data.db3&quot;;datetimeformat=Ticks'" 
 providerName="System.Data.EntityClient" />
</connectionStrings>

Now I tried the following to access the database using a relative path (all fails):

  1. dataContext = new dataEntities("Data Source=data.db3");
  2. dataContext = new dataEntities("Data Source=.\\data.db3");
  3. dataContext = new dataEntities("Data Source=data.db3;Version=3;DateTimeFormat=Ticks;");
  4. dataContext = new dataEntities("metadata=res://*/DataEntities.csdl|res://*/DataEntities.ssdl|res://*/DataEntities.msl;provider=System.Data.SQLite;provider connection string='data source=&quot;data.db3&quot;;datetimeformat=Ticks'" providerName="System.Data.EntityClient");

Created by the ADO.Net framework:

public partial class dataEntities : ObjectContext
{

    public dataEntities() : base("name=dataEntities", "dataEntities")
    {
        this.ContextOptions.LazyLoadingEnabled = true;
        OnContextCreated();
    }

    public dataEntities(string connectionString) : base(connectionString, "dataEntities")
    {
        this.ContextOptions.LazyLoadingEnabled = true;
        OnContextCreated();
    }

 /// ……

}

  • 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-24T09:15:34+00:00Added an answer on May 24, 2026 at 9:15 am

    You might want to consider using the EntityConnectionStringBuilder class

    Which will simplify at least isolating the connection string down to just the SQL part.

    string baseFolder = AppDomain.CurrentDomain.BaseDirectory;
    
    string sqlLiteConnectionString = string.Format(
      "data source=\"{0}\";datetimeformat=Ticks", 
      Path.Combine(baseFolder, "data.db3"));
    
    var entityConnectionString = new EntityConnectionStringBuilder
    {
      Metadata = "res://*",
      Provider = "System.Data.EntityClient",
      ProviderConnectionString = sqlLiteConnectionString,
    }.ConnectionString;
    
    var entities = new dataEntities(entityConnectionString);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My application currently needs to upload a large amount of data to a database
I'm currently beta testing an application I'm working on. I've entered data into this
I am working on android sqLite database in which I am not able to
Is it possible to use a relative path to an SQLite database file in
I am working on a desktop application which uses SQLite to bulk insert tens
Am currently working on an application that requires users to submit posts and comments
Im currently working with an API which requires we send our collection details in
I'm working on the development of a C++ API which uses custom-designed plugins to
Currently working on database part of android project. The main aim of the project
I have an application currently on the app store which I intend to submit

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.