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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:24:19+00:00 2026-05-22T15:24:19+00:00

I have a Solution with multiple projects. One project is my DataAccess project with

  • 0

I have a Solution with multiple projects.

One project is my DataAccess project with 2 SQL CE databases defined, one for local users and one for company data, both with similar table structures. Public, static, readonly strings are defined for each database, and connections can be made.

Another project is my WPF project that will (eventually) display my data. To display data here, I have tried creating an Entity Context object, but nothing seems to work.

What is preventing me from accessing my data in the other project? (Currently, error states ‘data source’ is not defined)

How do I fix it?

AbcEntities abcContext;

public MainWindow() {
  InitializeComponent();
}

private void Window_Loaded(object sender, RoutedEventArgs e) {
  try {
    EntityConnection ec = new EntityConnection(DataClass.AbcConnectionString);
    abcContext= new AbcEntities(ec);
    listbox1.ItemsSource = from c in abcContext.Customers select c;
    abcCustomersBox.DisplayMemberPath = "Name";
  } catch (Exception err) {
    MessageBox.Show(err.Message);
  }
}
  • 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-22T15:24:20+00:00Added an answer on May 22, 2026 at 3:24 pm

    For others, I found out how to do this.

    In my static DataClass, I created the following routine to generate the Entity Connection String for me:

    static string BuildEntityConnString(string dbFileName, string resourceData, string password) {
      string resAll = @"res://*/";
      string dataSource = @"Data Source=|DataDirectory|\" + dbFileName;
      EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder();
      entityBuilder.Metadata = string.Format("{0}{1}.csdl|{0}{1}.ssdl|{0}{1}.msl", resAll, resourceData);
      entityBuilder.Provider = "System.Data.SqlServerCe.3.5";
      if (String.IsNullOrEmpty(password)) {
        entityBuilder.ProviderConnectionString = dataSource;
      } else {
        entityBuilder.ProviderConnectionString = dataSource + ";Password=" + password;
      }
      using (EntityConnection con = new EntityConnection()) {
        try {
          con.ConnectionString = entityBuilder.ToString();
          con.Open();
          Console.WriteLine("{0} Entity String created.", dbFileName);
          con.Close();
          return con.ConnectionString;
        } catch (Exception err) {
          Console.WriteLine(err);
        }
      }
      return null;
    }
    

    Notice that if there is any error, a NULL String is returned.

    If anyone wants to use this, they should either place a breakpoint at the Exception, throw it, or handle it in some way. The Console.WriteLine() was just for me to debug through this.

    I created Entity Connection Strings for my applications as follows:

    public static readonly string EntityConnString =
      BuildEntityConnString("sqlCeDb.sdf", "myModel", "abc123~Funky");
    

    Hope others get some mileage out of this.

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

Sidebar

Related Questions

my solution has multiple projects and in one of them I have the code
I have a solution in Visual Studio 2008 which has multiple projects. One of
I have a solution with several projects. One of them is a setup project.
I have a solution with many projects. One project contain few custom components. One
I have a solution with multiple projects and we need to do some serious
I have a solution with several projects, where the startup project has a post-build
I currently have a solution with multiple projects that mostly use the same classes.
I have a solution with multiple projects in it. When I want to debug
We have a solution with multiple web projects, and there are some pages that
I have a Solution where one project is the business layer and the other

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.