Load and save .sdf at runtime

563 views Asked by At

I'm building an C#-application that uses an SQL Server Compact 4.0 database (.sdf) with Entity Framework for data. I want to be able to load/save-files from within this application so that the user can load a different database or backup the database to an USB eg.

I know you can create an sdf in code, but how can i load it at runtime (The connectionstring)?

My question is that this must be a common thing to do, what is the best way to go about it? is there any guides out there to do this?

or do you reccomend another way to go about my problem?

//ObjectiveCoder

1

There are 1 answers

2
SLaks On

You should use a SqlCeConnectionStringBuilder to create a connection string containing your file path.