I created Console Application in C#. I have installed Entity Framework by NuGet for this solution.
I have class Person
:
public class Person {
public int Id { get; set; }
public string LastName { get; set; }
public string FirstName { get; set; }
public DateTime BirthDate { get; set; }
}
I have created db context:
public class ApplicationDbContext : DbContext {
public ApplicationDbContext()
: base("MiniProjekt") { }
public DbSet<Person> Persons { get; set; }
}
Enabled migrations in Package Manager Console. The database connection just works. I get valid data for the code below(I inserted some objects earlier), but I don't know where database is.
static void Main(string[] args) {
var context = new ApplicationDbContext();
Console.WriteLine(context.Persons.Count());
foreach (Person person in context.Persons) {
Console.WriteLine(person.LastName);
}
Console.ReadKey();
}
The problem is that I don't know where is .mdf
file with my database. I clicked Show All Files in Solution Explorer, went through my project files and I can't find it. I want to send this project later by mail and I would like to keep database file in the solution.
Question: How to import database file into my console application so it will be available by Solution Explorer(like in ASP.NET-MVC applicatons).
EDIT: Thanks to Frank I found the database but how to make it physically part of the Solution: