When I publish my ASP.NET Core 7 Web API on the Windows Plesk host, everything works fine, but when I try to connect and run a query to SQL Server database which is on host, I get this error:
FileNotFoundException: Could not load file or assembly 'Microsoft.Data.SqlClient, Version=5.0.0.0...
I decided to install Microsoft.Data.SqlClient
package (I don't know how to use it, I only installed it, but I still get the same error), and these are my packages:
I have two connection strings - one is in my DbContext
:
The other one is in my appSettings.json
(but there was no connection string on my appSettings.json
by default, I added it manually):
I don't know which connection string is used on host, but on my local computer 'DBContext ConnectionString' was working, and I even removed "TrustServerCertificate=True" and I changed the "Database=" to "Initial Catalog=" on both connection strings, still same error.
I found the solution, in ASP.NET Core 6, 7 and 8 after publishing there will be a folder named 'runtimes'. You're going to need it with the project files to deploy on IIS or Hosts.