Webmiscentral-client matching MySQL Database

Source: Internet
Author: User

Because of its own webmiscentral is EF5.0, so the adaptation is very simple, see below operation:

The 1.elegantwm.webui layer (or Elegantwm.dal) downloads mysql.data through NuGet 6.7.5

2. Modify the Web. config as follows:

<?xml version="1.0"?><!--For more information on what to configure your ASP. Application, please visit http://go.microsoft.com/fwlink/?linkid=152368--><configuration> <configSections> <section name="log4net"Type="log4net. Config.log4netconfigurationsectionhandler, Log4net"/> <sectiongroup name="Common"> <section name="Logging"Type="Common.Logging.ConfigurationSectionHandler, common.logging"/> </sectionGroup><section name= "entityframework" type= "System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, version=5.0.0.0, Culture=neutral, publickeytoken=b77a5c561934e089 "requirePermission=" false "/> </configSections> <log4net configsource="Log4netfile.xml"></log4net> <connectionStrings> <!--master database, supports multiple databases--<add name="Sqlserverdb"Providername="System.Data.SqlClient"connectionstring="Server=localhost; Uid=sa; pwd=o;database=cn9295;"/><add name= "Defaultdb" providername= "MySql.Data.MySqlClient" connectionstring= "Data source=localhost; Port=3306;initial catalog=wmc;uid=assp;pwd=assp123; Character Set=utf8; "/></connectionStrings> <appSettings> <!--system name--<add key="SysName"Value="wmc-client"/> <!--please go to http://saas.chinacloudtech.com Registered Account --<add key="Groupcode"Value=""/> <add key="Sysid"Value=""/> <add key="SSO"Value="http://saas.chinacloudtech.com"/> <add key="webpages:version"Value="2.0.0.0"/> <add key="webpages:enabled"Value="true"/> <add key="Preserveloginurl"Value="true"/> <add key="clientvalidationenabled"Value="true"/> <add key="unobtrusivejavascriptenabled"Value="true"/> </appSettings> <system.web>    .....  </system.web> <system.webServer>    ......  </system.webServer> <runtime>    ........  </runtime><system.data> <DbProviderFactories> <remove invariant= "MySql.Data.MySqlClient"/> <a DD name= "MySQL data Provider" invariant= "MySql.Data.MySqlClient" description= ". Net Framework Data Provider for MySQL" Typ E= "MySql.Data.MySqlClient.MySqlClientFactory, Mysql.data, version=6.7.5.0, Culture=neutral, publickeytoken= C5687fc88969c44d "/> </DbProviderFactories> </system.data></configuration>

Notice that the blue section above is new and the rest is not moving.

Where: connectionstrings you can arbitrarily add different types or the same type of multiple database connection strings, because in the WMC database connection string is refined to the object, different objects can have different connection strings, that is, the operation of different databases

3. Change the DBContext.cs of Elegantwm.dal to the following:

namespaceelegantwm.dal{ Public classDb:dbcontext {//Public static readonly log4net. ILog log = log4net. Logmanager.getlogger (System.Reflection.MethodBase.GetCurrentMethod ().        DeclaringType); //Configure the connection string, default database Defaultdb         PublicDB (string_connectstr):Base(_connectstr) {//   This is the previous practice  //Database.Connection.ConnectionString = Configurationmana Ger. CONNECTIONSTRINGS[_CONNECTSTR]. ToString (); Database.setinitializer<db> (NULL); //This . configuration.lazyloadingenabled = false;}

4. Unfortunately MySQL timestamp rowversion in C # EF support is not good, need to change byte[] to DateTime, So you need to change the rowversion type in the Elegantwm.entitymodel inside Entity.cs and IEntity.cs to DateTime.

5.OK, you can use MySQL.

6.MYSQL monitor EF SQL Tools EFProf.exe, charge, free 30-day trial, use up or very convenient powerful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.