I have an exception when I use sql.data.client to query database sqlserver :
system.platformnotsupportedexception microsoft.data.sqlclient is not supported on this platform
My code source :
using (var connection = new SqlConnection(connectionString))
{
using (var cmd = new SqlCommand(queryString, connection))
{
cmd.Connection = connection;
connection.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
return true;
}
}
}
}
Is not supported on this platform error typically means you tried to load an x64 assembly in a x86 process or vice versa.
Microsoft.Data.SqlClient contains architecture specific files.
Double check your Nuget Package is for the correct architecture your machine supports.