mirror of https://github.com/abpframework/abp.git
23 changed files with 610 additions and 43 deletions
@ -1,13 +1,12 @@ |
|||
using System.Threading.Tasks; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.Abp.Uow |
|||
{ |
|||
public interface ITransactionApi |
|||
public interface ITransactionApi : IDisposable |
|||
{ |
|||
void Commit(); |
|||
|
|||
Task CommitAsync(); |
|||
|
|||
void Dispose(); |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
using System; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.Tests.SecondContext |
|||
{ |
|||
public class Class1 |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
// <auto-generated />
|
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Metadata; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using Microsoft.EntityFrameworkCore.Storage; |
|||
using Microsoft.EntityFrameworkCore.Storage.Internal; |
|||
using System; |
|||
using Volo.Abp.EntityFrameworkCore.TestApp.SecondContext; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.Tests.SecondContext.Migrations |
|||
{ |
|||
[DbContext(typeof(SecondDbContext))] |
|||
[Migration("20170927075606_Initial_Migration")] |
|||
partial class Initial_Migration |
|||
{ |
|||
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("ProductVersion", "2.0.0-rtm-26452"); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.EntityFrameworkCore.TestApp.SecondContext.BookInSecondDbContext", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd(); |
|||
|
|||
b.Property<string>("Name"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.ToTable("Books"); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.Tests.SecondContext.Migrations |
|||
{ |
|||
public partial class Initial_Migration : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.CreateTable( |
|||
name: "Books", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "BLOB", nullable: false), |
|||
Name = table.Column<string>(type: "TEXT", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_Books", x => x.Id); |
|||
}); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "Books"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
// <auto-generated />
|
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Metadata; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using Microsoft.EntityFrameworkCore.Storage; |
|||
using Microsoft.EntityFrameworkCore.Storage.Internal; |
|||
using System; |
|||
using Volo.Abp.EntityFrameworkCore.TestApp.SecondContext; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.Tests.SecondContext.Migrations |
|||
{ |
|||
[DbContext(typeof(SecondDbContext))] |
|||
partial class SecondDbContextModelSnapshot : ModelSnapshot |
|||
{ |
|||
protected override void BuildModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("ProductVersion", "2.0.0-rtm-26452"); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.EntityFrameworkCore.TestApp.SecondContext.BookInSecondDbContext", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd(); |
|||
|
|||
b.Property<string>("Name"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.ToTable("Books"); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netcoreapp2.0</TargetFramework> |
|||
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
|||
<AssemblyName>Volo.Abp.EntityFrameworkCore.Tests.SecondContext</AssemblyName> |
|||
<PackageId>Volo.Abp.EntityFrameworkCore.Tests.SecondContext</PackageId> |
|||
<PreserveCompilationContext>true</PreserveCompilationContext> |
|||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> |
|||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> |
|||
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Volo.Abp.EntityFrameworkCore\Volo.Abp.EntityFrameworkCore.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" /> |
|||
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" /> |
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.0.0" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,29 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.TestApp.SecondContext |
|||
{ |
|||
[DependsOn(typeof(AbpEntityFrameworkCoreModule))] |
|||
public class AbpEfCoreTestSecondContextModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddAssemblyOf<AbpEfCoreTestSecondContextModule>(); |
|||
} |
|||
|
|||
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
|||
{ |
|||
SeedTestData(context); |
|||
} |
|||
|
|||
private static void SeedTestData(ApplicationInitializationContext context) |
|||
{ |
|||
using (var scope = context.ServiceProvider.CreateScope()) |
|||
{ |
|||
scope.ServiceProvider |
|||
.GetRequiredService<SecondContextTestDataBuilder>() |
|||
.Build(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using Volo.Abp.Domain.Entities; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.TestApp.SecondContext |
|||
{ |
|||
public class BookInSecondDbContext : AggregateRoot |
|||
{ |
|||
public string Name { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Domain.Repositories; |
|||
using Volo.Abp.Guids; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.TestApp.SecondContext |
|||
{ |
|||
public class SecondContextTestDataBuilder : ITransientDependency |
|||
{ |
|||
private readonly IRepository<BookInSecondDbContext> _bookRepository; |
|||
private readonly IGuidGenerator _guidGenerator; |
|||
|
|||
public SecondContextTestDataBuilder(IRepository<BookInSecondDbContext> bookRepository, IGuidGenerator guidGenerator) |
|||
{ |
|||
_bookRepository = bookRepository; |
|||
_guidGenerator = guidGenerator; |
|||
} |
|||
|
|||
public void Build() |
|||
{ |
|||
_bookRepository.Insert(new BookInSecondDbContext |
|||
{ |
|||
Id = _guidGenerator.Create(), |
|||
Name = "TestBook1" |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.TestApp.SecondContext |
|||
{ |
|||
public class SecondDbContext : AbpDbContext<SecondDbContext> |
|||
{ |
|||
public DbSet<BookInSecondDbContext> Books { get; set; } |
|||
|
|||
public SecondDbContext(DbContextOptions<SecondDbContext> options) |
|||
: base(options) |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Design; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.TestApp.SecondContext |
|||
{ |
|||
public class SecondDbContextFactory : IDesignTimeDbContextFactory<SecondDbContext> |
|||
{ |
|||
public SecondDbContext CreateDbContext(string[] args) |
|||
{ |
|||
var builder = new DbContextOptionsBuilder<SecondDbContext>(); |
|||
builder.UseSqlite(@"Data Source=d:\temp\VoloAbpEfCoreTestModule.db;"); |
|||
return new SecondDbContext(builder.Options); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,66 @@ |
|||
// <auto-generated />
|
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Metadata; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using Microsoft.EntityFrameworkCore.Storage; |
|||
using Microsoft.EntityFrameworkCore.Storage.Internal; |
|||
using System; |
|||
using Volo.Abp.TestApp.Domain; |
|||
using Volo.Abp.TestApp.EntityFrameworkCore; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.Tests.Migrations |
|||
{ |
|||
[DbContext(typeof(TestAppDbContext))] |
|||
[Migration("20170927080244_Initial_Migration")] |
|||
partial class Initial_Migration |
|||
{ |
|||
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("ProductVersion", "2.0.0-rtm-26452"); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.TestApp.Domain.Person", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd(); |
|||
|
|||
b.Property<int>("Age"); |
|||
|
|||
b.Property<string>("Name"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.ToTable("People"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.TestApp.Domain.Phone", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd(); |
|||
|
|||
b.Property<string>("Number"); |
|||
|
|||
b.Property<Guid>("PersonId"); |
|||
|
|||
b.Property<int>("Type"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("PersonId"); |
|||
|
|||
b.ToTable("AppPhones"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.TestApp.Domain.Phone", b => |
|||
{ |
|||
b.HasOne("Volo.Abp.TestApp.Domain.Person") |
|||
.WithMany("Phones") |
|||
.HasForeignKey("PersonId") |
|||
.OnDelete(DeleteBehavior.Cascade); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,60 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.Tests.Migrations |
|||
{ |
|||
public partial class Initial_Migration : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.CreateTable( |
|||
name: "People", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "BLOB", nullable: false), |
|||
Age = table.Column<int>(type: "INTEGER", nullable: false), |
|||
Name = table.Column<string>(type: "TEXT", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_People", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AppPhones", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<long>(type: "INTEGER", nullable: false) |
|||
.Annotation("Sqlite:Autoincrement", true), |
|||
Number = table.Column<string>(type: "TEXT", nullable: true), |
|||
PersonId = table.Column<Guid>(type: "BLOB", nullable: false), |
|||
Type = table.Column<int>(type: "INTEGER", nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AppPhones", x => x.Id); |
|||
table.ForeignKey( |
|||
name: "FK_AppPhones_People_PersonId", |
|||
column: x => x.PersonId, |
|||
principalTable: "People", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AppPhones_PersonId", |
|||
table: "AppPhones", |
|||
column: "PersonId"); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "AppPhones"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "People"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,65 @@ |
|||
// <auto-generated />
|
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Metadata; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using Microsoft.EntityFrameworkCore.Storage; |
|||
using Microsoft.EntityFrameworkCore.Storage.Internal; |
|||
using System; |
|||
using Volo.Abp.TestApp.Domain; |
|||
using Volo.Abp.TestApp.EntityFrameworkCore; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.Tests.Migrations |
|||
{ |
|||
[DbContext(typeof(TestAppDbContext))] |
|||
partial class TestAppDbContextModelSnapshot : ModelSnapshot |
|||
{ |
|||
protected override void BuildModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("ProductVersion", "2.0.0-rtm-26452"); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.TestApp.Domain.Person", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd(); |
|||
|
|||
b.Property<int>("Age"); |
|||
|
|||
b.Property<string>("Name"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.ToTable("People"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.TestApp.Domain.Phone", b => |
|||
{ |
|||
b.Property<long>("Id") |
|||
.ValueGeneratedOnAdd(); |
|||
|
|||
b.Property<string>("Number"); |
|||
|
|||
b.Property<Guid>("PersonId"); |
|||
|
|||
b.Property<int>("Type"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("PersonId"); |
|||
|
|||
b.ToTable("AppPhones"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.TestApp.Domain.Phone", b => |
|||
{ |
|||
b.HasOne("Volo.Abp.TestApp.Domain.Person") |
|||
.WithMany("Phones") |
|||
.HasForeignKey("PersonId") |
|||
.OnDelete(DeleteBehavior.Cascade); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Design; |
|||
|
|||
namespace Volo.Abp.TestApp.EntityFrameworkCore |
|||
{ |
|||
public class TestAppDbContextFactory : IDesignTimeDbContextFactory<TestAppDbContext> |
|||
{ |
|||
public TestAppDbContext CreateDbContext(string[] args) |
|||
{ |
|||
var builder = new DbContextOptionsBuilder<TestAppDbContext>(); |
|||
builder.UseSqlite(@"Data Source=d:\temp\VoloAbpEfCoreTestModule.db;"); |
|||
return new TestAppDbContext(builder.Options); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue