1. Create a "WCF Service Application".
2. Add a reference to the internal class library, EntityFramework (Version 6.2). Mysql.data, MySql.Data.Entity.EF6 (Version 6.9.9)
3. Configure the Web. config
1 <?XML version= "1.0" encoding= "Utf-8"?>2 <Configuration>3 <configsections>4 <!--for more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -5 < Sectionname= "EntityFramework"type= "System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, version=6.0.0.0, culture= Neutral, publickeytoken=b77a5c561934e089 "requirepermission= "false" />6 <!--for more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -7 </configsections>8 <appSettings>9 <AddKey= "Aspnet:usetaskfriendlysynchronizationcontext"value= "true" />Ten </appSettings> One <system.web> A <compilationDebug= "true" /> - </system.web> - <EntityFramework> the <providers> - <providerInvariantName= "MySql.Data.MySqlClient"type= "MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, version=6.9.9.0, Culture=neutral, Publickeytoken=c5687fc88969c44d "></provider> - <providerInvariantName= "System.Data.SqlClient"type= "System.Data.Entity.SqlServer.SqlProviderServices, entityframework.sqlserver" /> - </providers> + <defaultconnectionfactorytype= "System.Data.Entity.Infrastructure.LocalDbConnectionFactory, entityframework"> - <Parameters> + <parametervalue= "Mssqllocaldb" /> A </Parameters> at </defaultconnectionfactory> - </EntityFramework> - <System.ServiceModel> - <Services> - <Servicebehaviorconfiguration= "Behav1"name= "Services.getserverinfoservice"> - <EndpointAddress=""binding= "Wshttpbinding"bindingconfiguration=""Contract= "Contracts.igetserverinfo" /> in <EndpointAddress= "Mex"binding= "mexHttpBinding"bindingconfiguration=""Contract= "IMetadataExchange" /> - </Service> to </Services> + <Behaviors> - <servicebehaviors> the <Behaviorname= "Behav1"> * <Servicemetadatahttpgetenabled= "true"httpsgetenabled= "true" /> $ <ServicedebugIncludeexceptiondetailinfaults= "true" />Panax Notoginseng </Behavior> - </servicebehaviors> the </Behaviors> + <servicehostingenvironmentaspnetcompatibilityenabled= "false"multiplesitebindingsenabled= "true" /> A </System.ServiceModel> the <connectionStrings> + <Addname= "Testentities"connectionString= "metadata=res://*/model1.csdl|res://*/model1.ssdl|res://*/model1.msl;provider=mysql.data.mysqlclient; Provider connection String="server=localhost;user Id=root;password=123456;persistsecurityinfo=true; database=test" "ProviderName= "System.Data.EntityClient" /> - <Addname= "TestEntities2"connectionString= "metadata=res://*/model2.csdl|res://*/model2.ssdl|res://*/model2.msl;provider=mysql.data.mysqlclient; Provider connection String="server=localhost;user Id=root;password=123456;persistsecurityinfo=true; database=test" "ProviderName= "System.Data.EntityClient" /> $ </connectionStrings> $ <system.webserver> - <Modulesrunallmanagedmodulesforallrequests= "true" /> - <!-- the to browse the Web application root directory during debugging, set the following value to True. - Setting this value to False prior to deployment avoids revealing WEB application folder information. Wuyi - the <Directorybrowseenabled= "true" /> - </system.webserver> Wu <System.Data> - <dbproviderfactories> About <Removeinvariant= "MySql.Data.MySqlClient" /> $ <Addname= "MySQL Data Provider"invariant= "MySql.Data.MySqlClient"Description= ". Net Framework Data Provider for MySQL"type= "MySql.Data.MySqlClient.MySqlClientFactory, Mysql.data, version=6.9.9.0, Culture=neutral, publickeytoken= C5687fc88969c44d " /> - </dbproviderfactories> - </System.Data >
</Configuration>
4. Create the Svc file:
Content: <%@ ServiceHost language= "C #" debug= "true" service= "Services.getserverinfoservice"%>
5. Set IIS, right-click: Add Application
HTTP 404.2-not Found "The contents of the IIS 7.5 request appear to be scripts and therefore cannot be handled by a static file handler
http://blog.csdn.net/testcs_dn/article/details/8726480
C:\Windows\Microsoft.NET\Framework\V4.0.30319\aspnet_regiis-i
5. Set up Application pools: Advanced: Enable 32-bit applications True
4.0 is set to allow
The settings for the handler mappings.
Access Address: Http://localhost//IISHostService/Service.svc
Https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-host-a-wcf-service-in-iis
Http://www.cnblogs.com/kesalin/archive/2012/08/20/host_wcf_in_iss.html
Wcf+ef+mysql posted on IIS7