Browse Source

Upgrade to EF Core 2.1.0-preview1-final

pull/272/head
Halil İbrahim Kalkan 8 years ago
parent
commit
0c6501bc29
  1. 4
      src/Volo.Abp.EntityFrameworkCore/Volo.Abp.EntityFrameworkCore.csproj
  2. 37
      test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927075606_Initial_Migration.Designer.cs
  3. 29
      test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927075606_Initial_Migration.cs
  4. 49
      test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927100405_Added_PhoneInSecondDbContext.Designer.cs
  5. 18
      test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927100405_Added_PhoneInSecondDbContext.cs
  6. 48
      test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/SecondDbContextModelSnapshot.cs
  7. 12
      test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo.Abp.EntityFrameworkCore.Tests.SecondContext.csproj
  8. 15
      test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo/Abp/EntityFrameworkCore/TestApp/SecondContext/SecondDbContextFactory.cs
  9. 8
      test/Volo.Abp.EntityFrameworkCore.Tests/Volo.Abp.EntityFrameworkCore.Tests.csproj
  10. 6
      test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/AbpEntityFrameworkCoreTestModule.cs
  11. 34
      test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/TestMigrationsDbContext.cs
  12. 15
      test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/TestApp/EntityFrameworkCore/TestAppDbContextFactory.cs

4
src/Volo.Abp.EntityFrameworkCore/Volo.Abp.EntityFrameworkCore.csproj

@ -18,8 +18,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.0-preview1-final" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.1.0-preview1-final" />
</ItemGroup>
</Project>

37
test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927075606_Initial_Migration.Designer.cs

@ -1,37 +0,0 @@
// <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
}
}
}

29
test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927075606_Initial_Migration.cs

@ -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<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");
}
}
}

49
test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927100405_Added_PhoneInSecondDbContext.Designer.cs

@ -1,49 +0,0 @@
// <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("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<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Name");
b.HasKey("Id");
b.ToTable("Books");
});
modelBuilder.Entity("Volo.Abp.EntityFrameworkCore.TestApp.SecondContext.PhoneInSecondDbContext", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Number");
b.HasKey("Id");
b.ToTable("AppPhones");
});
#pragma warning restore 612, 618
}
}
}

18
test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/20170927100405_Added_PhoneInSecondDbContext.cs

@ -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)
{
}
}
}

48
test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Migrations/SecondDbContextModelSnapshot.cs

@ -1,48 +0,0 @@
// <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");
});
modelBuilder.Entity("Volo.Abp.EntityFrameworkCore.TestApp.SecondContext.PhoneInSecondDbContext", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Number");
b.HasKey("Id");
b.ToTable("AppPhones");
});
#pragma warning restore 612, 618
}
}
}

12
test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo.Abp.EntityFrameworkCore.Tests.SecondContext.csproj

@ -18,15 +18,5 @@
<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.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.0.1" />
</ItemGroup>
</Project>

15
test/Volo.Abp.EntityFrameworkCore.Tests.SecondContext/Volo/Abp/EntityFrameworkCore/TestApp/SecondContext/SecondDbContextFactory.cs

@ -1,15 +0,0 @@
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);
}
}
}

8
test/Volo.Abp.EntityFrameworkCore.Tests/Volo.Abp.EntityFrameworkCore.Tests.csproj

@ -21,13 +21,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.1" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.0-preview1-final" />
</ItemGroup>
</Project>

6
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<TestAppDbContext>().Database.Migrate();
context.ServiceProvider.GetRequiredService<SecondDbContext>().Database.Migrate();
}
@ -50,12 +49,11 @@ namespace Volo.Abp.EntityFrameworkCore
var connection = new SqliteConnection("Data Source=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<TestAppDbContext>().UseSqlite(connection).Options;
using (var context = new TestAppDbContext(options))
using (var context = new TestMigrationsDbContext(new DbContextOptionsBuilder<TestMigrationsDbContext>().UseSqlite(connection).Options))
{
context.GetService<IRelationalDatabaseCreator>().CreateTables();
}
return connection;
}
}

34
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<TestMigrationsDbContext>
{
public DbSet<Person> People { get; set; }
public DbSet<City> Cities { get; set; }
public DbSet<ThirdDbContextDummyEntity> DummyEntities { get; set; }
public DbSet<BookInSecondDbContext> Books { get; set; }
public TestMigrationsDbContext(DbContextOptions<TestMigrationsDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Phone>(b =>
{
b.HasKey(p => new { p.PersonId, p.Number });
});
}
}
}

15
test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/TestApp/EntityFrameworkCore/TestAppDbContextFactory.cs

@ -1,15 +0,0 @@
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…
Cancel
Save