C
C#8mo ago
Adam

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
Keswiik
Keswiik8mo ago
what error?
Adam
AdamOP8mo ago
CS0234
Keswiik
Keswiik8mo ago
Have you done a nuget restore? If you added the reference manually it may not have actually loaded the package.
Adam
AdamOP8mo ago
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
Keswiik
Keswiik8mo ago
What IDE are you using?
Adam
AdamOP8mo ago
Visual studio code fixed itself with system restart :when:
Want results from more Discord servers?
Add your server