Syed Haris Ali Ghaznavi Syed Haris Ali Ghaznavi - 3 years ago 180
ASP.NET (C#) Question

Default account controller not creating database in MVC 5

I am creating a web application in ASP.NET MVC5. when i created the project a controller named AccountController was added automatically with all the necessary functions. now when i run the application and register a new user or try to login it gives some error. When i run it, it should create a database in App_data but its not creating any database and giving the following error. can anyone help me solve it please

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]

the connection string is:

<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-EmployeeOrderSystem-20160710042802.mdf;Initial Catalog=aspnet-EmployeeOrderSystem-20160710042802;Integrated Security=True" providerName="System.Data.SqlClient" />

if any other detail is needed please ask. Thanks in advance

Answer Source

When you create a new MVC 5 application and choose "Individual User Accounts", a new ASP.NET Identity Provider is included which uses Entity Framework 6 Code-First.When Identity is accessed for the first time, Entity Framework checks to see if the database exists. Unless configured otherwise, it uses the "DefaultConnection" to find the identity database. If the database does not exist when Identity is called, EF automatically created the database.When the first user is registered, database to be created.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download