Reputation: 1686
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.
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?
Upvotes: 0
Views: 2592
Reputation: 181
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.
Upvotes: 1
Reputation: 1
The folder App_Data wasn't there, then I created the folder and run the application (f5). The EF created the .mdf files without problem.
Upvotes: 0
Reputation: 440
Solution:
Problem: The App_Data folder still doesn’t show anything.
Solution:
Go back to visual studio and refresh the App_Data folder.
Upvotes: 0