1,依赖注入
EntityframeworkDemoSchemaDbMigrator : IDemoSchemaDbMigrator, ITransientDependency
约定:实现类后面的命令必须包含DemoSchemaDbMigrator
2,appsettings.json
①始终复制
<ItemGroup> <Content Include="appsettings.json"> <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> </ItemGroup>
②嵌入的资源
<ItemGroup> <None Remove="TemplatesFilesHello.tpl" /> <EmbeddedResource Include="TemplatesFilesHello.tpl" /> </ItemGroup>
<ItemGroup> <EmbeddedResource Include="LocalizationFiles*.json" /> <Content Remove="LocalizationFiles*.json" /> </ItemGroup>
3,迁移程序执行流程
4,Hw_ScheduDbContextModelCreatingExtensions
builder.Entity<TaskInfo>(b=>{ b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "TaskInfos"); b.ConfigureByConvention(); b.Property(x=>x.Name).HasMaxLength(TaskInfoConsts.MaxNameLength).IsRequired(); b.Property(x=>x.Remark).HasMaxLength(TaskInfoConsts.MaxRemarkLength); b.Property(x=>x.Api).HasMaxLength(TaskInfoConsts.MaxApiLength).IsRequired(); b.Property(x=>x.Cron).HasMaxLength(TaskInfoConsts.MaxCronLength).IsRequired(); b.Property(x=>x.Status).IsRequired(); b.Property(x=>x.SystemInfoId).IsRequired(); b.Property(x=>x.CreationTime).HasColumnType("datetime").HasDefaultValueSql("now()").IsRequired(); b.Property(x=>x.LastModificationTime).HasColumnType("datetime").HasDefaultValueSql("now()").IsRequired(); b.Property(x=>x.DeletionTime).HasColumnType("datetime").HasDefaultValueSql("now()").IsRequired(); b.HasIndex(x=>x.SystemInfoId); });