views:

322

answers:

1

I'm making a WinForms app in C#. When I go to create my database object, I'm presented with two options:

  • Local Database
  • Service-based Database

All I want is a simple local database to use for my project.

However, if I select "Local Database (Compact Edition)" then after I create my tables and drag them over to a LINQ-To-SQL Class creator it says:

The selected object(s) use an unsupported data provider.

So, I don't know why creating a local database would be considered an unsupported provider when dragging to tables to the Object Relational designer.

So, I try the second type, "Service-based Database". I lay out my tables how I want for my basic application and make my tables. The LINQ-To-SQL Designer works fine when I drag these tables and I proceed to write my code in my app to insert and upate the database entries.

However, with this second "Service-based Database" my inserts and updates work as long as the application is running. However, once I close it it reverts back to what it was before. If I manually add in data via the Server Explorer it persists but any inserts I do don't save.

Why can't I create and use a Local Database with LINQ?

If that isn't an option, then why isn't the "Service-Based Database" (whatever that is), persisting beyond the application closing?

Thanks for your time!


Edit: Apparently the LINQ-To-SQL Object Designer doesn't work on Compact Edition Local Databases. It can still be done, but you have to use SqlMetal apparently to generate the dmbl file.

+2  A: 

When you compile, the old database gets erased and a new one is copied to the bin folder. Therefore try link (using linq) to the database in the bin folder. Try change your connectionString.

Fredrick