mirror of https://github.com/abpframework/abp.git
Browse Source
Closes: https://github.com/abpframework/abp/issues/4099 Closes: https://github.com/abpframework/abp/issues/4152pull/4164/head
20 changed files with 740 additions and 0 deletions
@ -0,0 +1,21 @@ |
|||
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00 |
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlobStoring.Database.Host.ConsoleApp.ConsoleApp", "src\BlobStoring.Database.Host.ConsoleApp.ConsoleApp\BlobStoring.Database.Host.ConsoleApp.ConsoleApp.csproj", "{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}" |
|||
EndProject |
|||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E8067AED-2B6E-4134-AAF8-9101457D709A}" |
|||
EndProject |
|||
Global |
|||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|||
Debug|Any CPU = Debug|Any CPU |
|||
Release|Any CPU = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(NestedProjects) = preSolution |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2} = {E8067AED-2B6E-4134-AAF8-9101457D709A} |
|||
EndGlobalSection |
|||
EndGlobal |
|||
@ -0,0 +1,23 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.BlobStoring; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp |
|||
{ |
|||
public class BlobService : IBlobService, ITransientDependency |
|||
{ |
|||
private readonly IBlobContainer<ProfilePictureContainer> _container; |
|||
|
|||
public BlobService(IBlobContainer<ProfilePictureContainer> container) |
|||
{ |
|||
_container = container; |
|||
} |
|||
|
|||
public async Task SaveFile(string fileName = "File Name", string fileContent = "File Content") |
|||
{ |
|||
await _container.SaveAsync(fileName, fileContent.GetBytes(), true); |
|||
Console.WriteLine($"File: {fileName} is successfully saved"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>netcoreapp3.1</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Remove="appsettings.json" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<EmbeddedResource Include="appsettings.json" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\..\..\framework\src\Volo.Abp.EntityFrameworkCore.SqlServer\Volo.Abp.EntityFrameworkCore.SqlServer.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\src\Volo.Abp.BlobStoring.Database.EntityFrameworkCore\Volo.Abp.BlobStoring.Database.EntityFrameworkCore.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.4" /> |
|||
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" /> |
|||
<PackageReference Include="Serilog.Sinks.Async" Version="1.4.0" /> |
|||
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" /> |
|||
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" /> |
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.2" /> |
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.2" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,32 @@ |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Serilog; |
|||
using Volo.Abp; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp |
|||
{ |
|||
public class ConsoleAppConsoleAppHostedService : IHostedService |
|||
{ |
|||
public async Task StartAsync(CancellationToken cancellationToken) |
|||
{ |
|||
using (var application = AbpApplicationFactory.Create<ConsoleAppConsoleAppModule>(options => |
|||
{ |
|||
options.UseAutofac(); |
|||
options.Services.AddLogging(c => c.AddSerilog()); |
|||
})) |
|||
{ |
|||
application.Initialize(); |
|||
|
|||
var blobService = application.ServiceProvider.GetService<BlobService>(); |
|||
|
|||
await blobService.SaveFile("Test File 2", "Test Content 2"); |
|||
|
|||
application.Shutdown(); |
|||
} |
|||
} |
|||
|
|||
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; |
|||
} |
|||
} |
|||
@ -0,0 +1,56 @@ |
|||
using BlobStoring.Database.Host.ConsoleApp.ConsoleApp.EfCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.BlobStoring; |
|||
using Volo.Abp.BlobStoring.Database; |
|||
using Volo.Abp.BlobStoring.Database.EntityFrameworkCore; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore.SqlServer; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp |
|||
{ |
|||
|
|||
[DependsOn( |
|||
typeof(AbpAutofacModule), |
|||
typeof(AbpEntityFrameworkCoreSqlServerModule), |
|||
typeof(BlobStoringDatabaseEntityFrameworkCoreModule) |
|||
)] |
|||
public class ConsoleAppConsoleAppModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
ConfigureEntityFramework(context); |
|||
|
|||
context.Services.AddSingleton<IBlobProvider, DatabaseBlobProvider>(); |
|||
|
|||
Configure<AbpBlobStoringOptions>(options => |
|||
{ |
|||
options.Containers.ConfigureDefault(container => |
|||
{ |
|||
container.ProviderType = typeof(DatabaseBlobProvider); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureEntityFramework(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpDbConnectionOptions>(options => |
|||
{ |
|||
options.ConnectionStrings.Default = "Server=localhost;Database=BlobStoring_Host;Trusted_Connection=True;MultipleActiveResultSets=true"; |
|||
}); |
|||
|
|||
context.Services.AddAbpDbContext<BlobStoringHostDbContext>(options => |
|||
{ |
|||
options.AddDefaultRepositories(true); |
|||
}); |
|||
|
|||
Configure<AbpDbContextOptions>(x => |
|||
{ |
|||
x.UseSqlServer(); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Volo.Abp.BlobStoring.Database.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp.EfCore |
|||
{ |
|||
public class BlobStoringHostDbContext : AbpDbContext<BlobStoringHostDbContext> |
|||
{ |
|||
public BlobStoringHostDbContext(DbContextOptions<BlobStoringHostDbContext> options) : base(options) |
|||
{ |
|||
} |
|||
|
|||
protected override void OnModelCreating(ModelBuilder modelBuilder) |
|||
{ |
|||
base.OnModelCreating(modelBuilder); |
|||
|
|||
modelBuilder.ConfigureBlobStoring(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
using System.IO; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Design; |
|||
using Microsoft.Extensions.Configuration; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp.EfCore |
|||
{ |
|||
public class BlobStoringHostDbContextFactory : IDesignTimeDbContextFactory<BlobStoringHostDbContext> |
|||
{ |
|||
public BlobStoringHostDbContext CreateDbContext(string[] args) |
|||
{ |
|||
var configuration = BuildConfiguration(); |
|||
|
|||
var builder = new DbContextOptionsBuilder<BlobStoringHostDbContext>() |
|||
.UseSqlServer(configuration.GetConnectionString("Default")); |
|||
|
|||
return new BlobStoringHostDbContext(builder.Options); |
|||
} |
|||
|
|||
private static IConfigurationRoot BuildConfiguration() |
|||
{ |
|||
var builder = new ConfigurationBuilder() |
|||
.SetBasePath(Directory.GetCurrentDirectory()) |
|||
.AddJsonFile("appsettings.json", optional: false); |
|||
|
|||
return builder.Build(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp.EfCore |
|||
{ |
|||
public class BlobStoringHostDbSchemaMigrator : IBlobStoringHostDbSchemaMigrator, ITransientDependency |
|||
{ |
|||
private readonly IServiceProvider _serviceProvider; |
|||
|
|||
public BlobStoringHostDbSchemaMigrator(IServiceProvider serviceProvider) |
|||
{ |
|||
_serviceProvider = serviceProvider; |
|||
} |
|||
|
|||
public async Task MigrateAsync() |
|||
{ |
|||
await _serviceProvider |
|||
.GetRequiredService<BlobStoringHostDbContext>() |
|||
.Database |
|||
.MigrateAsync(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp.EfCore |
|||
{ |
|||
public interface IBlobStoringHostDbSchemaMigrator |
|||
{ |
|||
Task MigrateAsync(); |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp |
|||
{ |
|||
public interface IBlobService |
|||
{ |
|||
Task SaveFile(string fileName = "File Name", string fileContent = "File Content"); |
|||
} |
|||
} |
|||
@ -0,0 +1,97 @@ |
|||
// <auto-generated />
|
|||
using System; |
|||
using BlobStoring.Database.Host.ConsoleApp.ConsoleApp.EfCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Metadata; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp.Migrations |
|||
{ |
|||
[DbContext(typeof(BlobStoringHostDbContext))] |
|||
[Migration("20200531134550_Initial")] |
|||
partial class Initial |
|||
{ |
|||
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) |
|||
.HasAnnotation("ProductVersion", "3.1.4") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 128) |
|||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.BlobStoring.Database.DatabaseBlob", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasColumnName("ConcurrencyStamp") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<Guid>("ContainerId") |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.Property<byte[]>("Content") |
|||
.HasColumnType("varbinary(max)") |
|||
.HasMaxLength(2147483647); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnName("ExtraProperties") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasColumnType("nvarchar(256)") |
|||
.HasMaxLength(256); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "ContainerId", "Name"); |
|||
|
|||
b.ToTable("AbpBlobs"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.BlobStoring.Database.DatabaseBlobContainer", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasColumnName("ConcurrencyStamp") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnName("ExtraProperties") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasColumnType("nvarchar(128)") |
|||
.HasMaxLength(128); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "Name"); |
|||
|
|||
b.ToTable("AbpBlobContainers"); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp.Migrations |
|||
{ |
|||
public partial class Initial : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.CreateTable( |
|||
name: "AbpBlobContainers", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(nullable: false), |
|||
ExtraProperties = table.Column<string>(nullable: true), |
|||
ConcurrencyStamp = table.Column<string>(nullable: true), |
|||
TenantId = table.Column<Guid>(nullable: true), |
|||
Name = table.Column<string>(maxLength: 128, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpBlobContainers", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpBlobs", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(nullable: false), |
|||
ExtraProperties = table.Column<string>(nullable: true), |
|||
ConcurrencyStamp = table.Column<string>(nullable: true), |
|||
ContainerId = table.Column<Guid>(nullable: false), |
|||
TenantId = table.Column<Guid>(nullable: true), |
|||
Name = table.Column<string>(maxLength: 256, nullable: false), |
|||
Content = table.Column<byte[]>(maxLength: 2147483647, nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpBlobs", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpBlobContainers_TenantId_Name", |
|||
table: "AbpBlobContainers", |
|||
columns: new[] { "TenantId", "Name" }); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpBlobs_TenantId_ContainerId_Name", |
|||
table: "AbpBlobs", |
|||
columns: new[] { "TenantId", "ContainerId", "Name" }); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "AbpBlobContainers"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpBlobs"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,108 @@ |
|||
// <auto-generated />
|
|||
using System; |
|||
using BlobStoring.Database.Host.ConsoleApp.ConsoleApp.EfCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Metadata; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp.Migrations |
|||
{ |
|||
[DbContext(typeof(BlobStoringHostDbContext))] |
|||
[Migration("20200531143839_FK_Added")] |
|||
partial class FK_Added |
|||
{ |
|||
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) |
|||
.HasAnnotation("ProductVersion", "3.1.4") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 128) |
|||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.BlobStoring.Database.DatabaseBlob", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasColumnName("ConcurrencyStamp") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<Guid>("ContainerId") |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.Property<byte[]>("Content") |
|||
.HasColumnType("varbinary(max)") |
|||
.HasMaxLength(2147483647); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnName("ExtraProperties") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasColumnType("nvarchar(256)") |
|||
.HasMaxLength(256); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("ContainerId"); |
|||
|
|||
b.HasIndex("TenantId", "ContainerId", "Name"); |
|||
|
|||
b.ToTable("AbpBlobs"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.BlobStoring.Database.DatabaseBlobContainer", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasColumnName("ConcurrencyStamp") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnName("ExtraProperties") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasColumnType("nvarchar(128)") |
|||
.HasMaxLength(128); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "Name"); |
|||
|
|||
b.ToTable("AbpBlobContainers"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.BlobStoring.Database.DatabaseBlob", b => |
|||
{ |
|||
b.HasOne("Volo.Abp.BlobStoring.Database.DatabaseBlobContainer", null) |
|||
.WithMany() |
|||
.HasForeignKey("ContainerId") |
|||
.OnDelete(DeleteBehavior.Cascade) |
|||
.IsRequired(); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp.Migrations |
|||
{ |
|||
public partial class FK_Added : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpBlobs_ContainerId", |
|||
table: "AbpBlobs", |
|||
column: "ContainerId"); |
|||
|
|||
migrationBuilder.AddForeignKey( |
|||
name: "FK_AbpBlobs_AbpBlobContainers_ContainerId", |
|||
table: "AbpBlobs", |
|||
column: "ContainerId", |
|||
principalTable: "AbpBlobContainers", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropForeignKey( |
|||
name: "FK_AbpBlobs_AbpBlobContainers_ContainerId", |
|||
table: "AbpBlobs"); |
|||
|
|||
migrationBuilder.DropIndex( |
|||
name: "IX_AbpBlobs_ContainerId", |
|||
table: "AbpBlobs"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,106 @@ |
|||
// <auto-generated />
|
|||
using System; |
|||
using BlobStoring.Database.Host.ConsoleApp.ConsoleApp.EfCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Metadata; |
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp.Migrations |
|||
{ |
|||
[DbContext(typeof(BlobStoringHostDbContext))] |
|||
partial class BlobStoringHostDbContextModelSnapshot : ModelSnapshot |
|||
{ |
|||
protected override void BuildModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) |
|||
.HasAnnotation("ProductVersion", "3.1.4") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 128) |
|||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.BlobStoring.Database.DatabaseBlob", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasColumnName("ConcurrencyStamp") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<Guid>("ContainerId") |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.Property<byte[]>("Content") |
|||
.HasColumnType("varbinary(max)") |
|||
.HasMaxLength(2147483647); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnName("ExtraProperties") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasColumnType("nvarchar(256)") |
|||
.HasMaxLength(256); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("ContainerId"); |
|||
|
|||
b.HasIndex("TenantId", "ContainerId", "Name"); |
|||
|
|||
b.ToTable("AbpBlobs"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.BlobStoring.Database.DatabaseBlobContainer", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasColumnName("ConcurrencyStamp") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnName("ExtraProperties") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasColumnType("nvarchar(128)") |
|||
.HasMaxLength(128); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "Name"); |
|||
|
|||
b.ToTable("AbpBlobContainers"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.BlobStoring.Database.DatabaseBlob", b => |
|||
{ |
|||
b.HasOne("Volo.Abp.BlobStoring.Database.DatabaseBlobContainer", null) |
|||
.WithMany() |
|||
.HasForeignKey("ContainerId") |
|||
.OnDelete(DeleteBehavior.Cascade) |
|||
.IsRequired(); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp |
|||
{ |
|||
public class ProfilePictureContainer |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Serilog; |
|||
using Serilog.Events; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp |
|||
{ |
|||
public class Program |
|||
{ |
|||
public static async Task<int> Main(string[] args) |
|||
{ |
|||
Log.Logger = new LoggerConfiguration() |
|||
#if DEBUG
|
|||
.MinimumLevel.Debug() |
|||
#else
|
|||
.MinimumLevel.Information() |
|||
#endif
|
|||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
|||
.Enrich.FromLogContext() |
|||
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
|||
.WriteTo.Console() |
|||
.CreateLogger(); |
|||
|
|||
try |
|||
{ |
|||
Log.Information("Starting console host."); |
|||
await CreateHostBuilder(args).RunConsoleAsync(); |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, "Host terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
|
|||
} |
|||
|
|||
internal static IHostBuilder CreateHostBuilder(string[] args) => |
|||
Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args) |
|||
.ConfigureServices((hostContext, services) => |
|||
{ |
|||
services.AddHostedService<ConsoleAppConsoleAppHostedService>(); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
{ |
|||
"ConnectionStrings": { |
|||
"Default": "Server=localhost;Database=BlobStoring_Host;Trusted_Connection=True;MultipleActiveResultSets=true" |
|||
} |
|||
} |
|||
Loading…
Reference in new issue