Reputation: 496
I am creating an on-line shop project using .NET Core 3.0 and Entity Framework Core. I have set up the applicationContextDb
and the connection string in appSettings.json
.
The application works just fine adding products, and these products show up in my localdb in VS2019. I need it to connect to my localhost SQL Server instance in SSMS as it will be easier in the future to manage the online shop and see the data, but I don't know how to do that and I cannot find much information about this out there. Does anyone have an idea on how to do this?
I have tried to change the name from localdb to localhost, and obviously changing it too in the connection string, but it throws an error saying that it cannot find the network path.
Upvotes: 1
Views: 6308
Reputation: 89090
To connect to a local default SQL Server instance (which I agree is easier in the long run than localDB), use a connection string like:
"Server=localhost;database=YourDatabaseName;Integrated Security=true"
A named instance like
"Server=localhost\SqlExpress;database=YourDatabaseName;Integrated Security=true"
Of course you have to install the SQL Server instance before this will work. You can install using the Developer Edition or Express Edition available for free download here.
After pointing to the new instance, you'll need to run your Migrations, or run myDbContext.Database.EnsureCreated()
to generate the DDL for your EF model. Or copy the .mdf/.ldf into your SQL Server's data directory and Attach the database in SSMS.
Upvotes: 1