0
When I try to access data in Mysql via lambda
(EF
), Visual Studio returns the following error:
Falha no método >'MySql.Data.Entity.EFMySqlCommand.set_DbConnection(System.Data.Common.DbConnection)' ao tentar acessar o método 'MySql.Data.MySqlClient.MySqlConnection.get_Settings()'.
I tried searching the internet but I couldn’t 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, connector version . net 8.0.10-rc and plugin version of visual studio 2.0.5 M4
how you set up the connection?
– novic
I set it up right by ado.net
– Deivid Farias
So show the whole sequence, the problem seems to me to be at this point ... only the error itself has no way to be sure of anything!
– novic
All right, buddy, I posted the whole class.
– Deivid Farias
this -> remoteEntities
– novic
My entity, you’re wrong?
– Deivid Farias
can be so much, maybe the driver, maybe the connection I don’t know ... maybe ... it’s hard to reproduce your mistake.
– novic
What is strange is that I remove the connector, the plugin, the connection to the bank, remove everything and still when I add it again from the error.
– Deivid Farias