Browse Source

🗑️ delete(file): 删除 MySql 迁移相关文件以清理项目结构

pull/1067/head^2^2
feijie 1 year ago
parent
commit
00d96ec093
  1. 4
      aspnet-core/templates/aio/content/migrations/PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql/FodyWeavers.xml
  2. 30
      aspnet-core/templates/aio/content/migrations/PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql/FodyWeavers.xsd
  3. 22
      aspnet-core/templates/aio/content/migrations/PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql/PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql.csproj
  4. 59
      aspnet-core/templates/aio/content/migrations/PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql/README.en.md
  5. 59
      aspnet-core/templates/aio/content/migrations/PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql/README.md
  6. 32
      aspnet-core/templates/aio/content/migrations/PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql/SingleMigrationsDbContextFactory.cs
  7. 24
      aspnet-core/templates/aio/content/migrations/PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql/SingleMigrationsEntityFrameworkCoreMySqlModule.cs

4
aspnet-core/templates/aio/content/migrations/PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql/FodyWeavers.xml

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait />
</Weavers>

30
aspnet-core/templates/aio/content/migrations/PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql/FodyWeavers.xsd

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" />
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

22
aspnet-core/templates/aio/content/migrations/PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql/PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql.csproj

@ -1,22 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../../common.props" />
<Import Project="../../configureawait.props" />
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySql" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore\PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.csproj" />
</ItemGroup>
</Project>

59
aspnet-core/templates/aio/content/migrations/PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql/README.en.md

@ -1,59 +0,0 @@
# MySQL Database Migration Guide
This guide will help you manage MySQL database migrations using the migration scripts.
## Prerequisites
1. Ensure .NET Core SDK is installed
2. Ensure Entity Framework Core tools are installed
```powershell
dotnet tool install --global dotnet-ef
```
3. Ensure MySQL connection string is properly configured
## Usage Instructions
### 1. Create New Migration
1. Run the migration script in the `aspnet-core/migrations` directory:
```powershell
# Use English version
.\MigrateEn.ps1
# Or use Chinese version
.\Migrate.ps1
```
2. Select MySQL database context from the menu:
```
[1] PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql
```
3. Enter migration name (optional):
- Press Enter to use default name: `AddNewMigration_yyyyMMdd_HHmmss`
- Or enter custom name, e.g.: `AddNewFeature`
### 2. Generate SQL Script
After creating the migration, the script will ask if you want to generate SQL script:
1. Choose whether to generate SQL script (Y/N)
2. If Y is selected, following options will be available:
- `[A]` - Generate SQL script for all migrations
- `[L]` - Generate SQL script for latest migration only
- `[0-9]` - Generate from specified migration version
Generated SQL scripts will be saved in:
```
aspnet-core/InitSql/PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql/
```
### 3. Apply Migration
Generated SQL scripts can be applied to database through:
1. Using MySQL client tools to execute SQL script directly
2. Or using command line:
```powershell
mysql -u your_username -p your_database < your_script.sql
```

59
aspnet-core/templates/aio/content/migrations/PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql/README.md

@ -1,59 +0,0 @@
# MySQL 数据库迁移指南
本指南将帮助您使用迁移脚本来管理 MySQL 数据库的迁移操作。
## 前置条件
1. 确保已安装 .NET Core SDK
2. 确保已安装 Entity Framework Core 工具
```powershell
dotnet tool install --global dotnet-ef
```
3. 确保已正确配置 MySQL 连接字符串
## 使用说明
### 1. 创建新的迁移
1. 在 `aspnet-core/migrations` 目录下运行迁移脚本:
```powershell
# 使用中文版本
.\Migrate.ps1
# 或使用英文版本
.\MigrateEn.ps1
```
2. 在菜单中选择 MySQL 数据库上下文:
```
[1] PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql
```
3. 输入迁移名称(可选):
- 直接回车将使用默认名称:`AddNewMigration_yyyyMMdd_HHmmss`
- 或输入自定义名称,如:`AddNewFeature`
### 2. 生成 SQL 脚本
在创建迁移后,脚本会询问是否需要生成 SQL 脚本:
1. 选择是否生成 SQL 脚本 (Y/N)
2. 如果选择 Y,将提供以下选项:
- `[A]` - 生成所有迁移的 SQL 脚本
- `[L]` - 仅生成最新迁移的 SQL 脚本
- `[0-9]` - 从指定的迁移版本开始生成
生成的 SQL 脚本将保存在:
```
aspnet-core/InitSql/PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql/
```
### 3. 应用迁移
生成的 SQL 脚本可以通过以下方式应用到数据库:
1. 使用 MySQL 客户端工具直接执行 SQL 脚本
2. 或使用命令行:
```powershell
mysql -u your_username -p your_database < your_script.sql
```

32
aspnet-core/templates/aio/content/migrations/PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql/SingleMigrationsDbContextFactory.cs

@ -1,32 +0,0 @@
using PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
using System.IO;
namespace PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql;
public class SingleMigrationsDbContextFactory : IDesignTimeDbContextFactory<SingleMigrationsDbContext>
{
public SingleMigrationsDbContext CreateDbContext(string[] args)
{
var configuration = BuildConfiguration();
var connectionString = configuration.GetConnectionString("Default");
var builder = new DbContextOptionsBuilder<SingleMigrationsDbContext>()
.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString), b => b.MigrationsAssembly("PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql"));
return new SingleMigrationsDbContext(builder!.Options);
}
private static IConfigurationRoot BuildConfiguration()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Path.Combine(Directory.GetCurrentDirectory(),
"../PackageName.CompanyName.ProjectName.AIO.DbMigrator/"))
.AddJsonFile("appsettings.json", optional: false)
.AddJsonFile("appsettings.MySql.json", optional: true);
return builder.Build();
}
}

24
aspnet-core/templates/aio/content/migrations/PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql/SingleMigrationsEntityFrameworkCoreMySqlModule.cs

@ -1,24 +0,0 @@
using PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.MySQL;
using Volo.Abp.Modularity;
namespace PackageName.CompanyName.ProjectName.AIO.EntityFrameworkCore.MySql;
[DependsOn(
typeof(AbpEntityFrameworkCoreMySQLModule),
typeof(SingleMigrationsEntityFrameworkCoreModule)
)]
public class SingleMigrationsEntityFrameworkCoreMySqlModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDbContext<SingleMigrationsDbContext>();
Configure<AbpDbContextOptions>(options =>
{
options.UseMySQL();
});
}
}
Loading…
Cancel
Save