WebMisCentral-the Client adapts to the MySql database

Source: Internet
Author: User
WebMisCentral-the Client is compatible with MySql databases. because WebMisCentral uses EF5.0, it is very easy to adapt. The following describes the operation:

1. in the ElegantWM. WebUI layer (or ElegantWM. DAL), download MySQL. Data 6.7.5 through NUGET.

2. modify Web. config as follows:

 
 
 
  
   
   
    
   
   
     
  
  
  
   
   
  
  
  
  
   
.....
  
  
   
......
  
  
   
........
  
  
    
     
      
     
    
 

Note that the blue part above is newly added, and the rest is not required.

Specifically, you can add multiple database connection strings of different types or the same type in connectionStrings, because in WMC, database connection strings are refined to objects, different objects can have different connection strings, that is, they can operate on different databases.

3. modify DBContext. cs of ElegantWM. DAL to the following:

Namespace ElegantWM. DAL {public class DB: DbContext {// public static readonly log4net. ILog log = log4net. logManager. getLogger (System. reflection. methodBase. getCurrentMethod (). declaringType); // Configure the connection string. default database defadbdbpublic DB (string _ ConnectStr): base (_ ConnectStr){// This is the previous practice // Database. Connection. ConnectionString = ConfigurationManager. ConnectionStrings [_ ConnectStr]. ToString ();Database. SetInitializer
 
  
(Null); // this. Configuration. LazyLoadingEnabled = false ;}
 

4. sorry, the timestamp RowVersion in MySql does not support well in C # EF. you need to change byte [] to DateTime, so you need to change ElegantWM. entity in EntityModel. cs and IEntity. modify the RowVersion type in cs to DateTime.

5. OK. you can use MYSQL.

6. efprof.exe, a MySql tool for monitoring ef SQL, is free for 30 days. it is very convenient and powerful to use.

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.