Maybe these two links can help you, As a summary
Deleting the .vs directory: Close your development environment (such as Visual Studio), navigate to your project's root folder, delete the .vs directory, and then reopen the solution and attempt to rebuild it.
Deleting the solution's suo file: The suo file stores information about which files are open in the Integrated Development Environment (IDE). If the suo file is corrupt, it could cause the error you're encountering. You can delete this file without causing any significant damage to your project.
Checking the referenced SQL client: In some cases, the issue might be due to referencing Microsoft.Data.SqlClient instead of System.Data.SqlClient in your project. Changing the reference back to System.Data.SqlClient might resolve the error.