Error CS0234
using Microsoft.Data.SqlClient;
namespace DataAccessLibrary
{
public class SqlDataAccess
{
private readonly IConfiguration _config;
public string ConnectionStringName { get; set; } = "Default";
public SqlDataAccess(IConfiguration configuration)
{
_config = configuration;
}
public async Task<List<T>> LoadData<T, U>(string sql, U parameters)
{
string connectionString = _config.GetConnectionString(ConnectionStringName);
using(IDbConnection connection = new Microsoft.Data.SqlClient.SqlConnection(connectionString))
{
}
return null;
}
}
}
I get the error on the Microsoft.Data.SqlClient section, I have the package reference in my .csproj here:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.0" />
</ItemGroup>
</Project>
Any ideas on how to fix this?6 Replies
what error?
CS0234
Have you done a nuget restore?
If you added the reference manually it may not have actually loaded the package.
I’m not sure how to do that, I added the package using the cli and a nuget package manager and rebuilt the project
Both separate instances
What IDE are you using?
Visual studio code
fixed itself with system restart :when: