Search code examples
entity-frameworkvisual-studio-2012code-firstsql-server-express

How to switch from LocalDB instance to SQL Express?


I created an SQL Express database and built an Entity Data Model off of it using the wizard, then used the Repository Pattern to generate a helper class that does my querying for me.

Unfortunately what I didn't realize is that Code First creates a localdb copy and basically ALL my add/removes now go to this ethereal location that I can't find so I can't run queries off the data in SQL Express. Now I know the data is being saved because I'm able to check the underlying model through breakpoints and queries during page load with using(Context = new Context()) { /query stuff/ }, but I don't know how to switch from the underlying model back to my SqlExpress instance.

Any thoughts?


Solution

  • LocalDb is just another sql server database, which is started by Visual Studio. It's data most of the time are in %USER% directory and you can open it with Sql Server Management Studio. To switch your project to your sql express instance, you need to change the connection string, that's all.