I find it hard to understand how Entity Framework in Visual Studio is dealing with a LocalDB.
In my project root folder I have a .mdf
database file, let's call it MyDatabase.mdf
I'm using the MVVM pattern in my WPF application, so in my Model
folder, I added an ADO.NET Entity Data Model (code-first from database).
Now in the Server Explorer view I always add a Data Connection to this MyDatabase.mdf
, from here I can at least have some control over the database (like perform an EmptyDatabase
procedure or whatever).
Now the most single annoying thing is that whenever I run my project, somehow under the Debug folder a new MyDatabase.mdf
is created which has NO data in it.
In app.config
there is this tag:
<connectionStrings>
<add name="DysphagiaModel"
connectionString="data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\DysphagiaDB.mdf;integrated security=True;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework"
providerName="System.Data.SqlClient" />
</connectionStrings>
I just can't figure out why Entity Framework works this way, and I find it hard to find any good documentation for developers that are new to this. I'm used to working with PHP and MySQL, which really is a hell lot simpler than this. So this is really extremely frustrating, and I can't imagine I'm the only one having these issues with understanding how Visual Studio (and EF) works and how the underlying mechanics work.
Most articles and documentation out there already assume you know some mechanics, and they won't help you with referencing to what you need to know.
Anyway for this specific issue, how can I have my project use the database I have in my project's root folder?