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.
- Created a new ASP.Net web application, by selecting the Empty template and MVC ticked.
- Created a Model file called Employee and an EmployeeDBContext class. Made the required change in the Web.config
- 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; }
}
}
Web.Config
<connectionStrings>
<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?