0
votes

We currently are on a shared windows server through Hostgator. They are forcing the shared servers to run in Medium Trust. They have MySql.Data.DLL (6.9.7) in the GAC. The issue is they don't have MySql.Data.Entity.EF6.DLL in the GAC, nor will they install it for me. So I tried referencing there MySql.Data dll from the gac and then referencing the MySql.Data.Entity.EF6.dll (6.9.9) from our project. When I do this I get a security error. I am assuming this is due to the EF6 dll requiring full trust. Any solution to this? Thanks

Error:

{"Message":"An error has occurred.","ExceptionMessage":"Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.","ExceptionType":"System.Security.SecurityException","StackTrace":" at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)\r\n at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark)\r\n at System.Security.CodeAccessPermission.Demand()\r\n at System.Environment.GetEnvironmentVariable(String variable)\r\n at MySql.Data.MySqlClient.MySqlConnectAttrs.Is64BitOS()\r\n at MySql.Data.MySqlClient.MySqlConnectAttrs.get_Platform()"}

WebConfig:

<configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>

<entityFramework>
<providers>
    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
    <remove invariant="MySql.Data.MySqlClient" />
    <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.9.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>

<dependentAssembly>
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" />
<bindingRedirect oldVersion="0.0.0.0-6.9.9.0" newVersion="6.9.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="MySql.Data.Entity.EF6" publicKeyToken="c5687fc88969c44d" />
<bindingRedirect oldVersion="0.0.0.0-6.9.9.0" newVersion="6.9.9.0" />
</dependentAssembly>

enter image description here

1

1 Answers

0
votes

I do not know the Error which you mentioned.But i suggest you to read this page carefully https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html
Your WebConfig is not as below format

<connectionStrings>
    <add name="MyContext" providerName="MySql.Data.MySqlClient"
        connectionString="server=localhost;port=3306;database=mycontext;uid=root;password=********"/>
</connectionStrings>
<entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
    <providers>
        <provider invariantName="MySql.Data.MySqlClient"
            type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6"/>
        <provider invariantName="System.Data.SqlClient"
            type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
    </providers>
</entityFramework>