I recently started working on a new project based on .NET Core Framework 7. In this project, I'm using Entity Framework Core 7. However, when I try to build and run my project, I encounter an exception: 'A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.)' After searching online, I found a solution, so I thought I'd share it.
- [Solved]-How To Connect MySQL In ASP.NET Core 2024
- ASP .Net Core CRUD operations without using Entity Framework Step By Step Guide
- Crud operation in Asp .Net Core using Razor Pages Step By Step
- Crud operation in Asp.Net Core Mvc using jquery datatable with entity framework core database first
So let me share my thoughts on that. It's not a bug in EF Core 7.0 or 8.0; instead, it's an improved security feature. If you visit the Microsoft website, it suggests three options you can use:
1. Install a valid certificate.
2. Add 'TrustServerCertificate=True' to the connection string.
3. Add 'Encrypt=False' to the connection string.
Previously, SqlClient connection strings used 'Encrypt=False' by default. This allowed connections on development machines where the local server did not have a valid certificate.
However, in the latest version, SqlClient connection strings use 'Encrypt=True' by default.
This means the server must be configured with a valid certificate. That's why we now need to set the 'Encrypt' property to 'false' in case we don't have a valid certificate.
The connection string will look like the following:
Data Source=DESKTOP-MFLCOI2;Initial Catalog=HollyMelodyDb;User ID=sa;Password=adk@1234;Encrypt=false;
Read Similar Articles
- Download Sample MKV Video Files For Testing
- [Easy Way]-Receive File And Other Form Data Together In ASP.NET Core Web API
- How To Create Cursor in Sql Server With Example
- Simple way to Transpose Rows into columns using SQL Server
- How to Create a Stacked Bar Chart Using Chart Js Example?
- Save data using modal popup in asp net Core mvc with bootstrap jquery
- Checking if a Table Exists Using SQL Query in Entity Framework Core
- LCD/LED Energy Usage Calculator | What Is The Power Consumption Of a Tv
- [Best Way]-How To Display JSON Data In HTML Using Ajax