添加数据库迁移
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
using Domain.AggregateModel.AppAggregate;
|
||||
using Domain.AggregateModel.LinkAggregate;
|
||||
using Domain.SeedWork;
|
||||
using Infrastructure.EntityConfigurations;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Design;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@@ -34,13 +36,8 @@ namespace Infrastructure
|
||||
}
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
//modelBuilder.ApplyConfiguration(new ClientRequestEntityTypeConfiguration());
|
||||
//modelBuilder.ApplyConfiguration(new PaymentMethodEntityTypeConfiguration());
|
||||
//modelBuilder.ApplyConfiguration(new OrderEntityTypeConfiguration());
|
||||
//modelBuilder.ApplyConfiguration(new OrderItemEntityTypeConfiguration());
|
||||
//modelBuilder.ApplyConfiguration(new CardTypeEntityTypeConfiguration());
|
||||
//modelBuilder.ApplyConfiguration(new OrderStatusEntityTypeConfiguration());
|
||||
//modelBuilder.ApplyConfiguration(new BuyerEntityTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new AppEntityTypeConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new LinkEntityTypeConfiguration());
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +111,16 @@ namespace Infrastructure
|
||||
public AppDbContext CreateDbContext(string[] args)
|
||||
{
|
||||
var optionsBuilder = new DbContextOptionsBuilder<AppDbContext>()
|
||||
.UseMySql("Server=localhost;Database=qrcode;Uid=root;Pwd=root;");
|
||||
.UseMySql(
|
||||
"server=localhost;user=root;password=root;database=qrcode",
|
||||
// For common usages, see pull request #1233.
|
||||
new MariaDbServerVersion(new Version(10, 5, 9)), // use MariaDbServerVersion for MariaDB
|
||||
mySqlOptions => mySqlOptions
|
||||
.CharSetBehavior(CharSetBehavior.NeverAppend)
|
||||
.MigrationsAssembly("QRCodeService"))
|
||||
// Everything from this point on is optional but helps with debugging.
|
||||
.EnableSensitiveDataLogging()
|
||||
.EnableDetailedErrors();
|
||||
|
||||
return new AppDbContext(optionsBuilder.Options, new NoMediator());
|
||||
}
|
||||
|
||||
@@ -14,9 +14,11 @@ namespace Infrastructure.EntityConfigurations
|
||||
public void Configure(EntityTypeBuilder<Link> builder)
|
||||
{
|
||||
builder.ToTable("Link");
|
||||
builder.HasKey(l => l.ShortCode);
|
||||
builder.HasKey(l => l.Id);
|
||||
builder.HasIndex(l => l.ShortCode).IsUnique();
|
||||
builder.Ignore(l => l.DomainEvents);
|
||||
builder.Property(l => l.AppId).IsRequired();
|
||||
builder.Property(l => l.ShortCode).HasMaxLength(11);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,12 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.3" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.2.4" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.0-alpha.2" />
|
||||
<PackageReference Include="MySqlConnector" Version="1.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Domain\Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user