How to customize MySql Connector/net?

[亡魂溺海] 提交于 2019-12-19 04:11:46

问题


MySql Connector/Net is not working properly. The team working on bugs is only 3 people and they do not resolve complex issues. There are still unresolved issues from 2009. I want to customize their connector so that it works for my complex situation. How can I use a customized version in my project instead of theirs?


回答1:


Step 1) Download

In order to customize a version of oracle's mysql connector / net you are going to have to download the source code here: http://dev.mysql.com/downloads/connector/net/

Step 2) Open

Next, you are going to have to unzip the downloaded source files. The meat of the connector will be in two of the projects, MySql.Data and MySql.Data.Entity ( What is in a mysql provider? ).

Step 3) Edit The Connector

Make any edits to the classes you wish in order to fix your complex situation.

Step 4) Remove the signature

This step will make redistributing your edits undesirable, you may sign it and make the changes if you wish but for a local deployment it is unnecessary.

  • Inside of MySql.Data.Entity's AssemblyInfo.cs comment out this line:
    //[assembly: AssemblyKeyName("ConnectorNet")]
    

  • Inside of MySql.Data's AssemblyInfo.cs make these changes:
    //[assembly: AssemblyKeyName("ConnectorNet")]
    [assembly: InternalsVisibleTo("MySql.Data.Entity")]
    

    Step 5) Compile and Build In Order

    Build MySql.Data first. Once built, open MySql.Data.Entity. There will be a warning about not being able to find MySql.Data. Add the reference to the newly built MySql.Data inside of the bin/Debug folder. Build MySql.Data.Entity as Release.

    Step 6) Move the files

    Inside of the bin/Release folder of MySql.Data.Entity should be both MySql.Data and MySql.Data.Entity. Take each one and overwrite their counterparts in your project's package folder.

    Step 7) Update References in your project

    Inside of your project, go to the references area. Remove both MySql.Data and MySql.Data.Entity. Right click on References, click Add Reference, select the Browse tab, navigate to the package folder, and then add both MySql.Data and MySql.Data.Entity that you placed there in Step 6.

    Step 8) Modify web.config

    There will be several mentions of MySql.Data inside of web.config. Each one of them will have PublicKeyToken=c5687fc88969c44d which must be removed (from all of them).

    Step 9) Make it so

    Enjoy your customized connector!




    回答2:


    There is now a community-developed open-source .NET connection library for MySQL: https://github.com/mysql-net/MySqlConnector.

    It provides true async I/O (for high scalability) and fixes many bugs in Oracle's Connector/NET.



    来源:https://stackoverflow.com/questions/12944570/how-to-customize-mysql-connector-net

  • 易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
    该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!