11 changed files with 443 additions and 2 deletions
@ -0,0 +1,228 @@ |
|||||
|
{ |
||||
|
"App": { |
||||
|
"ShowPii": true, |
||||
|
"SelfUrl": "http://127.0.0.1:30001/", |
||||
|
"CorsOrigins": "http://127.0.0.1:3100,http://127.0.0.1:30001", |
||||
|
"Urls": { |
||||
|
"Applications": { |
||||
|
"MVC": { |
||||
|
"RootUrl": "http://127.0.0.1:30001/", |
||||
|
"Urls": { |
||||
|
"Abp.Account.EmailConfirm": "Account/EmailConfirm", |
||||
|
"Abp.Account.EmailVerifyLogin": "Account/VerifyCode" |
||||
|
} |
||||
|
}, |
||||
|
"STS": { |
||||
|
"RootUrl": "http://127.0.0.1:30001/" |
||||
|
}, |
||||
|
"VueVbenAdmin": { |
||||
|
"RootUrl": "http://127.0.0.1:3100", |
||||
|
"Urls": { |
||||
|
"Abp.Account.EmailConfirm": "account/email-confirm" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
"Auditing": { |
||||
|
"AllEntitiesSelector": true |
||||
|
}, |
||||
|
"DistributedCache": { |
||||
|
"HideErrors": true, |
||||
|
"KeyPrefix": "LINGYUN.Abp.Application", |
||||
|
"GlobalCacheEntryOptions": { |
||||
|
"SlidingExpiration": "30:00:00", |
||||
|
"AbsoluteExpirationRelativeToNow": "60:00:00" |
||||
|
} |
||||
|
}, |
||||
|
"ConnectionStrings": { |
||||
|
"Default": "Server=127.0.0.1;Database=Platform-V70;User Id=sa;Password=yourStrong(!)Password;TrustServerCertificate=True" |
||||
|
}, |
||||
|
"DistributedLock": { |
||||
|
"IsEnabled": true, |
||||
|
"Redis": { |
||||
|
"Configuration": "127.0.0.1,defaultDatabase=14" |
||||
|
} |
||||
|
}, |
||||
|
"Elsa": { |
||||
|
"Features": { |
||||
|
"DefaultPersistence": { |
||||
|
"Enabled": true, |
||||
|
"ConnectionStringIdentifier": "Default", |
||||
|
"EntityFrameworkCore": { |
||||
|
"SqlServer": { |
||||
|
"Enabled": true |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
"Console": true, |
||||
|
"Http": true, |
||||
|
"Email": true, |
||||
|
"TemporalQuartz": true, |
||||
|
"JavaScriptActivities": true, |
||||
|
"UserTask": true, |
||||
|
"Conductor": true, |
||||
|
"Telnyx": true, |
||||
|
"BlobStoring": true, |
||||
|
"Emailing": true, |
||||
|
"Notification": true, |
||||
|
"Sms": true, |
||||
|
"IM": true, |
||||
|
"PublishWebhook": true, |
||||
|
"Webhooks": { |
||||
|
"Enabled": true, |
||||
|
"ConnectionStringIdentifier": "Default", |
||||
|
"EntityFrameworkCore": { |
||||
|
"SqlServer": { |
||||
|
"Enabled": true |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
"WorkflowSettings": { |
||||
|
"Enabled": true, |
||||
|
"ConnectionStringIdentifier": "Default", |
||||
|
"EntityFrameworkCore": { |
||||
|
"SqlServer": { |
||||
|
"Enabled": true |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
"Server": { |
||||
|
"BaseUrl": "http://127.0.0.1:30000" |
||||
|
} |
||||
|
}, |
||||
|
"Quartz": { |
||||
|
"UsePersistentStore": false, |
||||
|
"Properties": { |
||||
|
"quartz.jobStore.dataSource": "tkm", |
||||
|
"quartz.jobStore.type": "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz", |
||||
|
"quartz.jobStore.driverDelegateType": "Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz", |
||||
|
"quartz.dataSource.tkm.connectionString": "Server=127.0.0.1;Database=Platform-V70;User Id=sa;Password=yourStrong(!)Password;", |
||||
|
"quartz.dataSource.tkm.provider": "SqlServer", |
||||
|
"quartz.jobStore.clustered": "true", |
||||
|
"quartz.serializer.type": "json", |
||||
|
"quartz.dataSource.tkm.connectionStringName": "TaskManagement" |
||||
|
} |
||||
|
}, |
||||
|
"Redis": { |
||||
|
"IsEnabled": true, |
||||
|
"Configuration": "127.0.0.1,defaultDatabase=15", |
||||
|
"InstanceName": "LINGYUN.Abp.Application" |
||||
|
}, |
||||
|
"AuthServer": { |
||||
|
"UseOpenIddict": true, |
||||
|
"Authority": "http://127.0.0.1:30001/", |
||||
|
"ApiName": "lingyun-abp-application", |
||||
|
"SwaggerClientId": "InternalServiceClient", |
||||
|
"SwaggerClientSecret": "1q2w3E*" |
||||
|
}, |
||||
|
"IdentityServer": { |
||||
|
"Clients": { |
||||
|
"VueAdmin": { |
||||
|
"ClientId": "vue-admin-client", |
||||
|
"RootUrl": "http://127.0.0.1:3100/" |
||||
|
}, |
||||
|
"InternalService": { |
||||
|
"ClientId": "InternalServiceClient" |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
"OpenIddict": { |
||||
|
"Applications": { |
||||
|
"VueAdmin": { |
||||
|
"ClientId": "vue-admin-client", |
||||
|
"RootUrl": "http://127.0.0.1:3100/" |
||||
|
}, |
||||
|
"InternalService": { |
||||
|
"ClientId": "InternalServiceClient" |
||||
|
} |
||||
|
}, |
||||
|
"Lifetime": { |
||||
|
"AuthorizationCode": "00:05:00", |
||||
|
"AccessToken": "14:00:00", |
||||
|
"DeviceCode": "00:10:00", |
||||
|
"IdentityToken": "00:20:00", |
||||
|
"RefreshToken": "14:00:00", |
||||
|
"RefreshTokenReuseLeeway": "00:00:30", |
||||
|
"UserCode": "00:10:00" |
||||
|
} |
||||
|
}, |
||||
|
"Identity": { |
||||
|
"Password": { |
||||
|
"RequiredLength": 6, |
||||
|
"RequiredUniqueChars": 0, |
||||
|
"RequireNonAlphanumeric": false, |
||||
|
"RequireLowercase": false, |
||||
|
"RequireUppercase": false, |
||||
|
"RequireDigit": false |
||||
|
}, |
||||
|
"Lockout": { |
||||
|
"AllowedForNewUsers": false, |
||||
|
"LockoutDuration": 5, |
||||
|
"MaxFailedAccessAttempts": 5 |
||||
|
}, |
||||
|
"SignIn": { |
||||
|
"RequireConfirmedEmail": false, |
||||
|
"RequireConfirmedPhoneNumber": false |
||||
|
} |
||||
|
}, |
||||
|
"FeatureManagement": { |
||||
|
"IsDynamicStoreEnabled": true |
||||
|
}, |
||||
|
"SettingManagement": { |
||||
|
"IsDynamicStoreEnabled": true |
||||
|
}, |
||||
|
"PermissionManagement": { |
||||
|
"IsDynamicStoreEnabled": true |
||||
|
}, |
||||
|
"TextTemplating": { |
||||
|
"IsDynamicStoreEnabled": true |
||||
|
}, |
||||
|
"WebhooksManagement": { |
||||
|
"IsDynamicStoreEnabled": true |
||||
|
}, |
||||
|
"Logging": { |
||||
|
"Serilog": { |
||||
|
"Elasticsearch": { |
||||
|
"IndexFormat": "abp.dev.logging-{0:yyyy.MM.dd}" |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
"AuditLogging": { |
||||
|
"Elasticsearch": { |
||||
|
"IndexPrefix": "abp.dev.auditing" |
||||
|
} |
||||
|
}, |
||||
|
"Elasticsearch": { |
||||
|
"NodeUris": "http://127.0.0.1:9200" |
||||
|
}, |
||||
|
"Serilog": { |
||||
|
"MinimumLevel": { |
||||
|
"Default": "Debug", |
||||
|
"Override": { |
||||
|
"System": "Warning", |
||||
|
"Microsoft": "Warning", |
||||
|
"DotNetCore": "Debug" |
||||
|
} |
||||
|
}, |
||||
|
"WriteTo": [ |
||||
|
{ |
||||
|
"Name": "Console", |
||||
|
"Args": { |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "Elasticsearch", |
||||
|
"Args": { |
||||
|
"nodeUris": "http://127.0.0.1:9200", |
||||
|
"indexFormat": "abp.dev.logging-{0:yyyy.MM.dd}", |
||||
|
"autoRegisterTemplate": true, |
||||
|
"autoRegisterTemplateVersion": "ESv7" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
<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.SqlServer" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\modules\elsa\LINGYUN.Abp.Elsa.EntityFrameworkCore.SqlServer\LINGYUN.Abp.Elsa.EntityFrameworkCore.SqlServer.csproj" /> |
||||
|
<ProjectReference Include="..\LY.MicroService.Applications.Single.EntityFrameworkCore\LY.MicroService.Applications.Single.EntityFrameworkCore.csproj" /> |
||||
|
</ItemGroup> |
||||
|
</Project> |
||||
@ -0,0 +1,59 @@ |
|||||
|
# SQL Server Database Migration Guide |
||||
|
|
||||
|
This guide will help you manage SQL Server 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 SQL Server 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 SQL Server database context from the menu: |
||||
|
``` |
||||
|
[3] LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer |
||||
|
``` |
||||
|
|
||||
|
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/LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer/ |
||||
|
``` |
||||
|
|
||||
|
### 3. Apply Migration |
||||
|
|
||||
|
Generated SQL scripts can be applied to database through: |
||||
|
|
||||
|
1. Using SQL Server Management Studio or other SQL Server client tools to execute SQL script |
||||
|
2. Or using command line: |
||||
|
```bash |
||||
|
sqlcmd -S your_server -d your_database -i your_script.sql |
||||
|
``` |
||||
@ -0,0 +1,59 @@ |
|||||
|
# SQL Server 数据库迁移指南 |
||||
|
|
||||
|
本指南将帮助您使用迁移脚本来管理 SQL Server 数据库的迁移操作。 |
||||
|
|
||||
|
## 前置条件 |
||||
|
|
||||
|
1. 确保已安装 .NET Core SDK |
||||
|
2. 确保已安装 Entity Framework Core 工具 |
||||
|
```powershell |
||||
|
dotnet tool install --global dotnet-ef |
||||
|
``` |
||||
|
3. 确保已正确配置 SQL Server 连接字符串 |
||||
|
|
||||
|
## 使用说明 |
||||
|
|
||||
|
### 1. 创建新的迁移 |
||||
|
|
||||
|
1. 在 `aspnet-core/migrations` 目录下运行迁移脚本: |
||||
|
```powershell |
||||
|
# 使用中文版本 |
||||
|
.\Migrate.ps1 |
||||
|
|
||||
|
# 或使用英文版本 |
||||
|
.\MigrateEn.ps1 |
||||
|
``` |
||||
|
|
||||
|
2. 在菜单中选择 SQL Server 数据库上下文: |
||||
|
``` |
||||
|
[3] LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer |
||||
|
``` |
||||
|
|
||||
|
3. 输入迁移名称(可选): |
||||
|
- 直接回车将使用默认名称:`AddNewMigration_yyyyMMdd_HHmmss` |
||||
|
- 或输入自定义名称,如:`AddNewFeature` |
||||
|
|
||||
|
### 2. 生成 SQL 脚本 |
||||
|
|
||||
|
在创建迁移后,脚本会询问是否需要生成 SQL 脚本: |
||||
|
|
||||
|
1. 选择是否生成 SQL 脚本 (Y/N) |
||||
|
2. 如果选择 Y,将提供以下选项: |
||||
|
- `[A]` - 生成所有迁移的 SQL 脚本 |
||||
|
- `[L]` - 仅生成最新迁移的 SQL 脚本 |
||||
|
- `[0-9]` - 从指定的迁移版本开始生成 |
||||
|
|
||||
|
生成的 SQL 脚本将保存在: |
||||
|
``` |
||||
|
aspnet-core/InitSql/LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer/ |
||||
|
``` |
||||
|
|
||||
|
### 3. 应用迁移 |
||||
|
|
||||
|
生成的 SQL 脚本可以通过以下方式应用到数据库: |
||||
|
|
||||
|
1. 使用 SQL Server Management Studio 或其他 SQL Server 客户端工具执行 SQL 脚本 |
||||
|
2. 或使用命令行: |
||||
|
```bash |
||||
|
sqlcmd -S your_server -d your_database -i your_script.sql |
||||
|
``` |
||||
@ -0,0 +1,35 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Design; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using System; |
||||
|
using System.IO; |
||||
|
|
||||
|
namespace LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer; |
||||
|
|
||||
|
public class SingleMigrationsDbContextFactory : IDesignTimeDbContextFactory<SingleMigrationsDbContext> |
||||
|
{ |
||||
|
public SingleMigrationsDbContext CreateDbContext(string[] args) |
||||
|
{ |
||||
|
var configuration = BuildConfiguration(); |
||||
|
var connectionString = configuration.GetConnectionString("Default"); |
||||
|
|
||||
|
var builder = new DbContextOptionsBuilder<SingleMigrationsDbContext>() |
||||
|
.UseSqlServer(connectionString, |
||||
|
b => b.MigrationsAssembly("LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer")); |
||||
|
|
||||
|
return new SingleMigrationsDbContext(builder!.Options); |
||||
|
} |
||||
|
|
||||
|
private static IConfigurationRoot BuildConfiguration() |
||||
|
{ |
||||
|
var builder = new ConfigurationBuilder() |
||||
|
.SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), |
||||
|
"../LY.MicroService.Applications.Single.DbMigrator/")) |
||||
|
.AddJsonFile("appsettings.json", optional: false) |
||||
|
.AddJsonFile( |
||||
|
"appsettings.SqlServer.json", |
||||
|
optional: false); |
||||
|
|
||||
|
return builder.Build(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
using LINGYUN.Abp.Elsa.EntityFrameworkCore.SqlServer; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using System; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Volo.Abp.EntityFrameworkCore.SqlServer; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AbpEntityFrameworkCoreSqlServerModule), |
||||
|
typeof(AbpElsaEntityFrameworkCoreSqlServerModule), |
||||
|
typeof(SingleMigrationsEntityFrameworkCoreModule) |
||||
|
)] |
||||
|
public class SingleMigrationsEntityFrameworkCoreSqlServerModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
context.Services.AddAbpDbContext<SingleMigrationsDbContext>(); |
||||
|
|
||||
|
Configure<AbpDbContextOptions>(options => |
||||
|
{ |
||||
|
options.UseSqlServer(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue