broccoli_soup
broccoli_soup

Reputation: 309

How to import existing mdf file into a lightswitch project?

I would like to copy table definitions from an existing database file into a new lightswitch project, does anyone know how to do that, it seems like you can only create a new database from scratch or attach an external database, but when i try to attach an external mdf file from another VS project I get an error which states: CREATE DATABASE Permission denied in database 'master'.

Any ideas about how to copy the table definitions from an existing database file into a lightswitch project?

Upvotes: 0

Views: 668

Answers (2)

Thomas Fonseca
Thomas Fonseca

Reputation: 542

As far as I know it can't be done. Lightswitch holds a representation of the database tables separate from the actual database definition. You can probably go the other way however because when the ApplicationDatabase.mdf file does not exist you can start Lightswitch (you will notice the table definitions are still in there) and then build the app which will recreate your ApplicationDatabase.mdf. It is empty of course but If you could find out where lightswitch stores those table definitions (an *.xaml file somewhere?) you might be able to get those copied into your project and then generate the ApplicationDatabase.mdf from there?

Upvotes: 0

julio.g
julio.g

Reputation: 3320

If you have the external database attached on an instance of SqlServer, you shouldn't have no problem attaching to it from LightSwitch. From that point on, you can rename tables and columns, change datatypes etc, as well as adding more tables and structures to that DB.
Note that the DB is supposed to be served from a SqlServer instance, not a file on your file system.

Upvotes: 1

Related Questions