Reputation: 2260
Using Entity 4.1 for a project, and couldn't figure out where the DB file been stored inside my project.
I think I've read that Entity code first will still store your data in SQL Express DB at a default location, but couldn't find out where it is.
What I did is:
create Entity DB project (Project A) in my solution, this project will have an Initializer to generate sample data for testing.
I also create a separate project (Project B) to save my Entity Code first data for testing by another application.
Then I create another WinForm project(Project C) in the same solution, and access DBContext from Project A.
I would assume that the DB should be somewhere in my Project C, and test projects in the solution shouldn't make a difference?
Upvotes: 0
Views: 1894
Reputation: 300
I know this is an ancient thread covering a different scenario, but google directed me here when I was trying to figure this out for a UWP app, so if anybody follows in my footsteps, here's my solution.
If you're using entity with sqlite in a windows app, your database file will likely be created in the "working directory" of your app. In this case it's:
C:\Users\<Username>\Local\Packages\{Package-Name}\LocalState\
you can find your {Package-Name} by looking in the app manifest. It'll probably be a long string of numbers and letters by default.
Upvotes: 1
Reputation: 177153
With a default installation of SQL Server Express and no connection string the database will be created in the DATA directory of the installation, for example something like: C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA
(for 2008 R2 version). The name of the database is namespace.contextname
, for example: MyNamespace.MyContext.mdf
(and .ldf). Under this name you can also find them in SQL Server Management Studio.
Upvotes: 1