.NET Application with SQL Server CE Database

Posted by blu on Stack Overflow See other posts from Stack Overflow or by blu
Published on 2010-03-25T23:03:55Z Indexed on 2010/03/27 19:43 UTC
Read the original article Hit count: 201

I just started using SQL Server CE 3.5 in my WinForms Application (C# in VS 2008 SP1).

I've noticed a couple of interesting things I'd like some input on:

1. Copying of sdf file to bin

My sdf file is located inside of an Infrastructure project that houses my repository implementations. When the application is first debugged the sdf was copied to debug\bin. This is where all future reads/writes operate.

At some point when this is deployed the file will go into a data folder using Click Once, but during development where should I be putting this sdf? Is having it in the bin typical, or are there any other recommendations?

2. Updating sdf

It appears that writing to the sdf file does not immediately update the database. I am using Linq-to-SQL and am calling SubmitChanges, but on read the values are not returned.

However if I close the application and re-open it the added value is there. Is there an additional flush step I need to take? What is causing this, file locking, buffering, something else?

Update

3. Unit Tests

I have an MS test project, and the sdf file is not being copied to the correct output directory. I have the settings:

Build Action: Content

Copy to Output Directory: Copy Always

The message is:

System.Data.SqlServerCe.SqlCeException: The database file cannot be found. Check the path to the database.

I appreciate any guidance on these questions, thanks. If there is a tutorial other than what is on MSDN that you know about that would be great too. Working with CE is proving to be a difficult task and I welcome any help I can find.

© Stack Overflow or respective owner

Related posts about sql-server-ce

Related posts about visual-studio-2008