none
Need help with my WPF project with SDF file and EDMX RRS feed

  • General discussion


  • Hello, 

    I made for myself, a WPF application to read the content of an hard drive, store data about the files in a local database and use Linq to find doubloons.

    Using VS2010, I was not able to use an SQL Compact 4.0 file so I have added a 3.5 SDF file, creating an empty database file.

    VS2010 has created a collection of "{mynameDataSet.*}" files and I am wondering if I need them in my scenario and what for.

    Then, I created my tables and added relations in my SDF file before adding an EDMX on top of it. My code works, I create objects, add to collections, save my context without errors but the file never gets updated !!!

    I also noticed that my SDF file gets copied to my BIN folder, I am surprised, should I do something to prevent that ?


    Here is my folder structure: 
    SDProject
    ---bin
    ------Debug
    ---------Data
    ------------SDProjectDB35.sdf
    ---------SDProject.exe
    ---------(...)
    ---Data
    ------SDProjectDB35.sdf
    ------SDProject35DataSet.xsd
    ------SDProjectDataModel.edmx
    ---App.config
    ---App.xaml
    ---MainWindow.xaml


    Here is a part of my code: 

    using (Data.SDProjectDataEntities ctx = new Data.SDProjectDataEntities(this.ConnString))
    {
    // Has changes never gets saved to file, this IF is always false !!
    if (ctx.UserSessions.Count() > 0)
    currentSession.Id = ctx.UserSessions.Max(i => i.Id);
    else
    currentSession.Id = 0;

    currentSession.Id++;

    ctx.AddToUserSessions(currentSession);
    ctx.SaveChanges( options:System.Data.Objects.SaveOptions.DetectChangesBeforeSave);
    }

    Thanks for any help, 
    Claude
    Monday, October 1, 2012 8:21 PM

All replies