After updating my Asp.Net Core MVC application from .NET 6 to 8, I have to include Encrypt=false in the SQL connection string

Sherpa 346 Reputation points
2025-07-09T17:53:46.2766667+00:00

EncryptError.pngWhile running my Asp.Net Core MVC application on .NET 6, the SQL server connection string didn't have any value regarding the "Encrypt". After updating to .NET 8, I have to include Encrypt=false in the connection string saved in the appSettings.json. If I didn't include it, or have it as "Encrypt=true", I am getting this error.

User's image

Developer technologies | ASP.NET | ASP.NET Core
0 comments No comments
{count} votes

Answer accepted by question author
  1. Raymond Huynh (WICLOUD CORPORATION) 4,235 Reputation points Microsoft External Staff Moderator
    2025-07-10T03:04:42.0166667+00:00

    Hi Sherpa,

    You're hitting this because of a breaking change in EF Core 7.0 (which .NET 8 uses). The Encrypt parameter now defaults to true instead of false.

    Quick fix:

    Add Encrypt=false to your connection string in appSettings.json:

    {
      "ConnectionStrings": {
        "DefaultConnection": "Server=your-server;Database=your-db;Trusted_Connection=true;Encrypt=false"
      }
    }
    

    Better fix (if you want to keep encryption):

    {
      "ConnectionStrings": {
        "DefaultConnection": "Server=your-server;Database=your-db;Trusted_Connection=true;Encrypt=true;TrustServerCertificate=true"
      }
    }
    

    The second option keeps encryption enabled but ignores certificate issues, which is good for development.

    Why this happened:

    Microsoft made encryption the default for better security. Your .NET 6 app worked because Encrypt defaulted to false, but .NET 8 defaults it to true.

    Just add Encrypt=false to your connection string and you'll be back up and running.

    Hope this help!

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. SurferOnWww 4,951 Reputation points
    2025-07-09T23:21:52.5166667+00:00

    It seems due to Breaking changes in EF Core 7.0 (EF7)

    See "Encrypt defaults to true for SQL Server connections" section in the above document.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.