Publish application with Entity Framework + Mysql

4

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 #

    
asked by anonymous 12.11.2014 / 00:56

2 answers

1

I've suffered a lot from this!

In locaweb, it only works with the MySqlConnector version below 6.3 or 5.3, I can not remember right!

Just download the old connector, replace the dlls, and change the versions of them in web.config! It's the only way!

At the time, I was so angry that I've been migrating some sites to the Web Hotel that already has the SQL Server database!

    
21.01.2015 / 01:51
0

Good morning, my friend,

I went through this problem and solved it with locaweb people, just adding the includesecurityasserts = true line between the webconfig parameters in the connection string, simple.

    
12.10.2015 / 17:40