Estou usando o Entity Framework
para Mysql
.
Instalei o .Net Connector
, e o MySQL.Data.Entities
.
Localmente está funcionando normalmente. Porém quando vou subir para o LocaWeb
, não vai.
Aparece o seguinte erro:
Cannot perform CAS Asserts in Security Transparent methods
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Cannot perform CAS Asserts in Security Transparent methods
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: Cannot perform CAS Asserts in Security Transparent methods]
MySql.Data.MySqlClient.MySqlClientFactory..ctor() +24
MySql.Data.Entity.MySqlEFConfiguration..ctor() +73[TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached,
Meu Web.config:
<connectionStrings>
<add name="BancoDados" providerName="MySql.Data.MySqlClient" connectionString="Data Source=xxxx; port=3306; Initial Catalog=bancoMySQL; uid=usuarioMySQL; pwd=qwe123qwe;" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.8.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
</providers>
</entityFramework>
Comecei a fazer algumas pesquisas e cheguei até uma referência da LocaWeb
:
LocaWeb no tópico:
MySqlConnector / Unable to find the requested .Net Framework Data Provider. It may not be installed
Então fazendo o que fala no tópico, adicionei
E
<system.data>
<DbProviderFactories>
<clear />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.8.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
Porém não surtiu efeito.
Até achei uma página na internet, porém não entendi muito bem o procedimento que falava, e acho que é o mesmo que recomenda a LocaWeb, mas vou deixar aqui o LINK
Copy Local = True
nas DLLs antes da publicação?