When I try to access the data in MySQL via lambda
( EF
), Visual Studio returns the following error:
Method 'MySql.Data.Entity.EFMySqlCommand.set_DbConnection (Method.Data.Common.DbConnection) failed' when trying to access method 'MySql.Data.MySqlClient.MySqlConnection.get_Settings ()'.
I tried searching the internet but did not find anything that could help me with this error. Follow the Main Controller Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity;
using MySql.Data.Entity;
using System.Media;
using View.Model;
using System.Security.Cryptography;
namespace View
{
public class MainController
{
remoteEntities remote = new remoteEntities();
public bool validaLogin(string usuario, string senha)
{
string novaSenha = getMD5Hash(senha);
var resultado = remote.Motorista.Select(x => new { x.ID, x.Login, x.Senha, x.Nome }).Where(u => u.Login == usuario && u.Senha == novaSenha).ToList();
if (resultado.Count > 0)
return true;
else
return false;
}
public static string getMD5Hash(string input)
{
var md5Hash = MD5.Create();
// Converter a String para array de bytes, que é como a biblioteca trabalha.
var data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
// Cria-se um StringBuilder para recompôr a string.
var sBuilder = new StringBuilder();
// Loop para formatar cada byte como uma String em hexadecimal
for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));
}
return sBuilder.ToString();
}
#region Testa Conexão
[System.Runtime.InteropServices.DllImport("wininet.dll")]
private static extern bool InternetGetConnectedState(out int Description, int ReservedValue);
public static bool checkConnection()
{
int desc;
bool hasConnection = InternetGetConnectedState(out desc, 0);
if (hasConnection)
hasConnection = webClient("http://zerohoravirtual.com/");
return hasConnection;
}
private static bool webClient(string _url)
{
System.Net.WebRequest webReq;
System.Net.WebResponse resp;
webReq = System.Net.WebRequest.Create(_url);
try
{
resp = webReq.GetResponse();
resp.Close();
webReq = null;
return true;
}
catch
{
webReq = null;
return false;
}
}
#endregion
}
}
Update 1
Connection created with ADO.Net, .net 8.0.10-rc connector version and visual studio plugin version 2.0.5 m4