In the previous section, we mentioned the powerful reverse engineering capabilities of XCode when establishing a database. Here, we will give an example on the local machine that uses the last entity, the code is still the code in the previous section, just modifying the Web. config can have a magical effect, and provide a Web-only. the connection field of Config, which is separated from the database copy code and method of the object.
If you are reading this article for the first time and do not have XCode DLL, read the previous log to obtain the DLL.
NewLife. XCode Getting Started Guide
Http://www.cnblogs.com/JangoJing/archive/2012/07/26/2610034.html
I. Reverse Engineering from SQL2005 to MySQL
In the previous section, my database was created in SQL2005. Here we will demonstrate how to generate a database in MySQL by modifying only Web. Config.
The first thing to introduce is the configuration of XCode. All the configurations of XCode can be seen through decompilation in XCode. DLL.
Here we will introduce several common configurations.
<! -- Whether to enable reverse engineering. Reverse Engineering is disabled by default. Reverse engineering allows you to reverse update the database structure through the entity class --> <add key = "XCode. Negative. Enable" value = "true"/>
This configuration is disabled by default. Only manual configuration is enabled. During XCode initialization, the connection field is automatically checked. If no database exists, a database is created. How does XCode work, for more information, see Xiao Dong's blog.
Understanding about reverse engineering of Xcode Database
Http://www.cnblogs.com/asxinyu/archive/2012/04/23/2467055.html
We will not discuss it in depth here. As long as we turn on this setting, XCode will automatically generate a database when the program starts, so the program you developed will be taken directly to your colleagues' computer, you can run the connection immediately after changing the connection field.
Note that the attribute declaration of an object, such as Student. cs, does not exist by default.
[ModelCheckModeAttribute(ModelCheckModes.CheckTableWhenFirstUse)]
Because he has a default value, the default value is to check all tables during the first run. Of course, he also has another value, which is used to check
We can configure it like this. Generally, you do not need to set it. Use the default settings.
Because MySQL is about to be used, we need to copy mysql. data. dll to our project. This file can be found in the Code Generator folder.
Next, modify Web. Config
First, turn on the reverse engineering switch and some other settings.
<Deleetask> <! -- Whether to enable debugging. By default, debugging is disabled. --> <add key = "XCode. Debug" value = "false"/> <! -- Whether to output SQL statements. By default, XCode debugging switch XCode. Debug --> <add key = "XCode. ShowSQL" value = "false"/> <! -- Sets the separate directory for SQL input. The default value is null. SQL output to the production environment of the current log is recommended to go to the separate SqlLog directory outside the site --> <add key = "XCode. SQLPath "value =" "/> <! -- Whether to enable reverse engineering is disabled by default. Reverse engineering allows you to reverse update the database structure through the entity class --> <add key = "XCode. Negative. Enable" value = "true"/> </deleettings>
Next, modify the connection field.
<connectionStrings> <!--<add name="XCodeTest" connectionString="Server=(local);User id=sa;Pwd=sa;Database=XCodeTest" providerName="System.Data.SqlClient"/>--> <add name="XCodeTest" connectionString="Server=.;Database=XCodeTest;Uid=root;Pwd=root;" providerName="MySql.Data.MySqlClient"/> </connectionStrings>
Take a look at MySql
Everything is ready. I only owe it to F5. After the program runs, it won't show any effect, but let's look at it in MySQL.
The table structure is complete, but there is no value in the table.
Because the LOG function is enabled in Web. Config, there is a LOG folder under the project root directory, which contains all our SQL statements. No other operations are performed here, so only these contents are available.
2. Remove the entity and use only 20 lines of code for full-database migration
For more information, see Xiao Dong's blog.
Use Xcode 20 lines of code to migrate any database
Http://www.cnblogs.com/asxinyu/archive/2012/04/26/2470838.html
This Demo (this Demo is only for testing in this section, and subsequent sections are not based on this Demo)
Http://dl.dbank.com/c0m1dmf1zw
XCode Getting Started Guide series:
NewLife. XCode Getting Started Guide
NewLife Forum address:
Http://www.53wb.com
Big stone blog:
Http://www.cnblogs.com/nnhy/
NewLife. XCode Development Resource Directory
Http://www.cnblogs.com/asxinyu/archive/2012/06/02/2532210.html