zoukankan      html  css  js  c++  java
  • WCF+EntityFramework+mysql总结

    前段时间搞一个项目,用WCF+Ef操作Mysql数据库的,现在,写一下经验总结,希望对大家有帮助。

    1.需下载并安装MySql Connector Net 6.5.4

    2.ef层和wcf服务层引用dll :Mysql.Data  MySql.Data.Entity  MySql.Web 三个dll.

    3.在ef层生成的config文件中,需要改动,把生成的* 改成efmodel所在程序的程序集名称.

    <connectionStrings>
        <add name="t" connectionString="metadata=res://WCFService.Data/PartsSaleMapping.csdl|res://WCFService.Data/PartsSaleMapping.ssdl|
    res://WCFService.Data/PartsSaleMapping.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;
    server=xxx;User Id=xxx;password=xxx;Persist Security Info=False;database=xxx&quot;
    " providerName="System.Data.EntityClient"/> </connectionStrings>

    4.在Service端config文件中加入mysql引擎

     <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.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" /> </DbProviderFactories> </system.data>

    5.如果客户端与服务端可有会有大数据传输时,修改下config文件

                    <binding name="BasicHttpBinding_ISaleService" closeTimeout="00:01:00"
                        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                        allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                        maxBufferSize="20000000" maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000"
                        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                        useDefaultWebProxy="true">
                        <readerQuotas maxDepth="32" maxStringContentLength="200000000" maxArrayLength="200000000"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />

    6.部署服务器,需要装.net framework4.0,服务器C盘下的machine.config,需要加入mysql引擎。

    7.部署的WCF的服务端访差距如果是带域名的,服务端Config文件按以下方式修改

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
    <baseAddressPrefixFilters>
    <add prefix="http://www.xxx.cn" />
    </baseAddressPrefixFilters>
    </serviceHostingEnvironment>

    Wcf服务标头中,加入:

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

    结束,总结到此:)

  • 相关阅读:
    LeetCode OJ 112. Path Sum
    LeetCode OJ 226. Invert Binary Tree
    LeetCode OJ 100. Same Tree
    LeetCode OJ 104. Maximum Depth of Binary Tree
    LeetCode OJ 111. Minimum Depth of Binary Tree
    LeetCode OJ 110. Balanced Binary Tree
    apache-jmeter-3.1的简单压力测试使用方法(下载和安装)
    JMeter入门教程
    CentOS6(CentOS7)设置静态IP 并且 能够上网
    分享好文:分享我在阿里8年,是如何一步一步走向架构师的
  • 原文地址:https://www.cnblogs.com/mahong/p/2752396.html
Copyright © 2011-2022 走看看