Cannot find .mdf file in App_data c# entity-framework-6


I am creating a basic MVC application using Visual Studio 2013 to list details of employees.And I am not able to find the Employee.mdf file in the App_data folder even though I can create new records. Here is the list of steps I have followed.

  1. Created a new ASP.Net web application, by selecting the Empty template and MVC ticked.
  2. Created a Model file called Employee and an EmployeeDBContext class. Made the required change in the Web.config
  3. Added an MVC controller with Views using Entity Framework and selected the Model class. So after scaffolding I am provided with a controller with Create,Edit,Delete options. I am able to do all these functionality which basically means there is a datbase.

But I am not able to find the .mdf file under the App_data folder.Here is my code sample.

Employee Model:

namespace Test1.Models
public class Employee
    public int EmployeeId { get; set; }
    public string Name { get; set; }
    public string City { get; set; }
    public int Salary { get; set; }

public class EmployeeDBContext : DbContext
    public DbSet<Employee> Employees { get; set; }


<add name="EmployeeDBContext"connectionString="Data Source=(LocalDB)\v11.0; AttachDbFilename=|DataDirectory|\Employees.mdf; 
Integrated Security=True" providerName="System.Data.SqlClient" />  </connectionStrings>

I have tried all the options provided in this solution Why is mdf file not appearing in the App_Data folder?

5/23/2017 10:33:00 AM

Popular Answer

Just if someone is still facing the problem, Run visual studio in debug mode and register a user and the mdf will be created in App_data.

12/16/2018 1:17:51 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow