diff --git a/src/Volo.Abp.EntityFrameworkCore/Volo.Abp.EntityFrameworkCore.csproj b/src/Volo.Abp.EntityFrameworkCore/Volo.Abp.EntityFrameworkCore.csproj
index d15c550d2b..b6cfcc2e61 100644
--- a/src/Volo.Abp.EntityFrameworkCore/Volo.Abp.EntityFrameworkCore.csproj
+++ b/src/Volo.Abp.EntityFrameworkCore/Volo.Abp.EntityFrameworkCore.csproj
@@ -18,8 +18,8 @@
-
-
+
+
diff --git a/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927075606_Initial_Migration.Designer.cs b/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927075606_Initial_Migration.Designer.cs
deleted file mode 100644
index 6c14d84718..0000000000
--- a/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927075606_Initial_Migration.Designer.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-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("Id")
- .ValueGeneratedOnAdd();
-
- b.Property("Name");
-
- b.HasKey("Id");
-
- b.ToTable("Books");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927075606_Initial_Migration.cs b/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927075606_Initial_Migration.cs
deleted file mode 100644
index 817d12ccd8..0000000000
--- a/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927075606_Initial_Migration.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-using System;
-
-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(type: "BLOB", nullable: false),
- Name = table.Column(type: "TEXT", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Books", x => x.Id);
- });
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "Books");
- }
- }
-}
diff --git a/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927100405_Added_PhoneInSecondDbContext.Designer.cs b/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927100405_Added_PhoneInSecondDbContext.Designer.cs
deleted file mode 100644
index 8330648646..0000000000
--- a/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927100405_Added_PhoneInSecondDbContext.Designer.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-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("20170927100405_Added_PhoneInSecondDbContext")]
- partial class Added_PhoneInSecondDbContext
- {
- 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("Id")
- .ValueGeneratedOnAdd();
-
- b.Property("Name");
-
- b.HasKey("Id");
-
- b.ToTable("Books");
- });
-
- modelBuilder.Entity("Volo.Abp.EntityFrameworkCore.TestApp.SecondContext.PhoneInSecondDbContext", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd();
-
- b.Property("Number");
-
- b.HasKey("Id");
-
- b.ToTable("AppPhones");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927100405_Added_PhoneInSecondDbContext.cs b/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927100405_Added_PhoneInSecondDbContext.cs
deleted file mode 100644
index e95c8c5ef1..0000000000
--- a/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927100405_Added_PhoneInSecondDbContext.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace Volo.Abp.EntityFrameworkCore.Tests.SecondContext.Migrations
-{
- public partial class Added_PhoneInSecondDbContext : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- /* SecondDbContext depends on TestAppDbContext,
- so no need to add migration for phones since TestAppDbContext already contains it */
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
-
- }
- }
-}
diff --git a/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/SecondDbContextModelSnapshot.cs b/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/SecondDbContextModelSnapshot.cs
deleted file mode 100644
index fb6518483a..0000000000
--- a/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/SecondDbContextModelSnapshot.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-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("Id")
- .ValueGeneratedOnAdd();
-
- b.Property("Name");
-
- b.HasKey("Id");
-
- b.ToTable("Books");
- });
-
- modelBuilder.Entity("Volo.Abp.EntityFrameworkCore.TestApp.SecondContext.PhoneInSecondDbContext", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd();
-
- b.Property("Number");
-
- b.HasKey("Id");
-
- b.ToTable("AppPhones");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo.Abp.EntityFrameworkCore.Tests.SecondContext.csproj b/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo.Abp.EntityFrameworkCore.Tests.SecondContext.csproj
index ff627ec05c..c731400de1 100644
--- a/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo.Abp.EntityFrameworkCore.Tests.SecondContext.csproj
+++ b/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo.Abp.EntityFrameworkCore.Tests.SecondContext.csproj
@@ -18,15 +18,5 @@
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo/Abp/EntityFrameworkCore/TestApp/SecondContext/SecondDbContextFactory.cs b/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo/Abp/EntityFrameworkCore/TestApp/SecondContext/SecondDbContextFactory.cs
deleted file mode 100644
index e7ee6375e6..0000000000
--- a/test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo/Abp/EntityFrameworkCore/TestApp/SecondContext/SecondDbContextFactory.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Design;
-
-namespace Volo.Abp.EntityFrameworkCore.TestApp.SecondContext
-{
- public class SecondDbContextFactory : IDesignTimeDbContextFactory
- {
- public SecondDbContext CreateDbContext(string[] args)
- {
- var builder = new DbContextOptionsBuilder();
- builder.UseSqlite(@"Data Source=d:\temp\VoloAbpEfCoreTestModule.db;");
- return new SecondDbContext(builder.Options);
- }
- }
-}
diff --git a/test/Volo.Abp.EntityFrameworkCore.Tests/Volo.Abp.EntityFrameworkCore.Tests.csproj b/test/Volo.Abp.EntityFrameworkCore.Tests/Volo.Abp.EntityFrameworkCore.Tests.csproj
index d313b0de19..c99f47c5a5 100644
--- a/test/Volo.Abp.EntityFrameworkCore.Tests/Volo.Abp.EntityFrameworkCore.Tests.csproj
+++ b/test/Volo.Abp.EntityFrameworkCore.Tests/Volo.Abp.EntityFrameworkCore.Tests.csproj
@@ -21,13 +21,7 @@
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/AbpEntityFrameworkCoreTestModule.cs b/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/AbpEntityFrameworkCoreTestModule.cs
index fc0414cb7f..6df4ec40b0 100644
--- a/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/AbpEntityFrameworkCoreTestModule.cs
+++ b/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/AbpEntityFrameworkCoreTestModule.cs
@@ -41,7 +41,6 @@ namespace Volo.Abp.EntityFrameworkCore
public override void OnPreApplicationInitialization(ApplicationInitializationContext context)
{
- context.ServiceProvider.GetRequiredService().Database.Migrate();
context.ServiceProvider.GetRequiredService().Database.Migrate();
}
@@ -50,12 +49,11 @@ namespace Volo.Abp.EntityFrameworkCore
var connection = new SqliteConnection("Data Source=:memory:");
connection.Open();
- var options = new DbContextOptionsBuilder().UseSqlite(connection).Options;
- using (var context = new TestAppDbContext(options))
+ using (var context = new TestMigrationsDbContext(new DbContextOptionsBuilder().UseSqlite(connection).Options))
{
context.GetService().CreateTables();
}
-
+
return connection;
}
}
diff --git a/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/TestMigrationsDbContext.cs b/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/TestMigrationsDbContext.cs
new file mode 100644
index 0000000000..cb9726d6b4
--- /dev/null
+++ b/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/TestMigrationsDbContext.cs
@@ -0,0 +1,34 @@
+using Microsoft.EntityFrameworkCore;
+using Volo.Abp.EntityFrameworkCore.TestApp.SecondContext;
+using Volo.Abp.EntityFrameworkCore.TestApp.ThirdDbContext;
+using Volo.Abp.TestApp.Domain;
+
+namespace Volo.Abp.EntityFrameworkCore
+{
+ public class TestMigrationsDbContext : AbpDbContext
+ {
+ public DbSet People { get; set; }
+
+ public DbSet Cities { get; set; }
+
+ public DbSet DummyEntities { get; set; }
+
+ public DbSet Books { get; set; }
+
+ public TestMigrationsDbContext(DbContextOptions options)
+ : base(options)
+ {
+
+ }
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ base.OnModelCreating(modelBuilder);
+
+ modelBuilder.Entity(b =>
+ {
+ b.HasKey(p => new { p.PersonId, p.Number });
+ });
+ }
+ }
+}
diff --git a/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/TestApp/EntityFrameworkCore/TestAppDbContextFactory.cs b/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/TestApp/EntityFrameworkCore/TestAppDbContextFactory.cs
deleted file mode 100644
index abe6ec9f70..0000000000
--- a/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/TestApp/EntityFrameworkCore/TestAppDbContextFactory.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Design;
-
-namespace Volo.Abp.TestApp.EntityFrameworkCore
-{
- public class TestAppDbContextFactory : IDesignTimeDbContextFactory
- {
- public TestAppDbContext CreateDbContext(string[] args)
- {
- var builder = new DbContextOptionsBuilder();
- builder.UseSqlite(@"Data Source=d:\temp\VoloAbpEfCoreTestModule.db;");
- return new TestAppDbContext(builder.Options);
- }
- }
-}