I'm using Entity Framework
to Mysql
.
I installed .Net Connector
, and MySQL.Data.Entities
.
Locally is working normally. But when I go up to LocaWeb
, it will not.
The following error appears:
Can not 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: Can not perform CAS Asserts in Security Transparent methods
Source Error:
An unhandled exception was generated during the execution of the current web request. Information about the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: Can not 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,
My 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>
I started to do some research and came up with a reference to LocaWeb
:
LocaWeb in topic:
MySqlConnector / Unable to find the requested .Net Framework Data Provider. It may not be installed
So doing what you say in the topic, I've added
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>
But it did not work.
I even found a page on the internet, but I did not quite understand the procedure I was talking about, and I think it's the same as what LocaWeb recommends, but I'll leave it here #