【问题标题】:Cant connect to Mysql master/slave using Entityframework无法使用实体框架连接到 Mysql 主/从
【发布时间】:2015-09-21 13:22:06
【问题描述】:

我有 mysql 主从配置,当我指定两个 ip 时我无法连接到它。我搜索连接字符串,发现http://www.connectionstrings.com/mysql-connector-net-mysqlconnection/

Server=serverAddress1, serverAddress2, serverAddress3;Database=myDataBase;
Uid=myUsername;Pwd=myPassword;

所以它看起来很简单,但是当我指定我的两个 ips 时,我收到错误“No such host is known

我还找到了https://blogs.oracle.com/MySqlOnWindows/entry/how_to_using_replication_load 并尝试了它,但奇怪的是它的速度要慢得多。所以现在我迷路了,我无法使用我的复制。

附言。我不确定这是否有意义,但我正在 Azure 上运行它

【问题讨论】:

    标签: mysql asp.net-mvc entity-framework azure


    【解决方案1】:

    您应该在特定的配置部分指定服务器

     <configSections>
        <section name="MySQL" type="MySql.Data.MySqlClient.MySqlConfiguration, MySql.Data, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
     </configSections>
     <MySQL>
       <Replication>
         <ServerGroups>
          <Group name="MasterSlave">
            <Servers>
              <Server name="master" IsMaster="true" connectionstring=" server=<server>;port=<port>;uid=<user>;password=<password>;"/>
              <Server name="slave" IsMaster="false" connectionstring=" server=<server>;port=<port>;uid=<user>;password=<password>;"/>
            </Servers>
          </Group>
        </ServerGroups>
      </Replication>
    </MySQL>  
    

    然后使用以下作为连接字符串:

    "server=MasterSlave;database=sakila;"
    

    来源:https://blogs.oracle.com/MySqlOnWindows/entry/how_to_using_replication_load

    【讨论】:

    • 这适用于 EntityFramework 吗?这意味着如果我使用此连接字符串创建 SQLConnection,我是否能够调用使用 EF 导入的存储过程?
    猜你喜欢
    • 2018-03-02
    • 1970-01-01
    • 2014-02-07
    • 2015-04-10
    • 2012-09-17
    • 1970-01-01
    • 2012-12-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多