Where is the database generated by my ASP.NET Core app?

294 Views Asked by At

I created an ASP.NET Core app and it has a database when I run it in Visual Studio, however I don't know where the database actually is and it doesn't have a database when I deploy it to IIS; it crashes when I try to access any data. How do I configure it to use a database when deployed to IIS? Ideally the same database from when I run it in Visual Studio?

1

There are 1 best solutions below

1
Chris Pratt On

By default Visual Studio uses LocalDb. If you go to the View menu in Visual Studio, and then click SQL Server Object Explorer, a panel will open listing the various SQL Server instances available. One should be MSSQLLocalDB. If you expand that, you should see your project's development database there.

As for production, you cannot use the same thing. This exists only in Visual Studio. For production, you'll need a real SQL Server instance (or MySQL, PostgreSQL, etc. now that EF Core supports additional database providers). Long and short, the database will not just appear for you magically as it does in development once you deploy. You'll need to set up a database server, create a database, apply your schema and then tell your project how to connect to it.