Debacle
Debacle

Reputation: 1221

WP7: How to create a database on install

I'm trying to create an application that mainly display information from the IsolatedStorage LINQ to SQL database I've created.

I'd like the application, on install, to load the database with the information. There's quite a bit of data.

I was curious as to what's the best method of doing something like this? Am I right to load the DB on install like this?

I'm very new to WP7 so I'm open to any ideas!

Thank you :)

Upvotes: 1

Views: 244

Answers (2)

Richard Szalay
Richard Szalay

Reputation: 84754

You cannot execute code during the installation process. You could do it on first load, but why make your users wait for it?

I would personally recommend creating the database as part of your build process (or manually if you aren't using CI/CD) and then deploying it with the application. You can then open the database from the application install directory as read-only (to avoid the copy to isolated storage).

If you have writes to make to the database, you could use a second database that lives in isolated storage for that.

Upvotes: 2

josemiguel.torres
josemiguel.torres

Reputation: 632

One of my apps deploy a 30Mb database file. To do so, you have to generate this database in a separate project, generate the database with Code First, download the database.sdf file from the emulator to your PC and add it as content to your primary project. I follow this article to reach it.

Upvotes: 1

Related Questions