[master] Update dependencies from dotnet/efcore (#20107)
* Update dependencies from https://github.com/dotnet/efcore build 20200324.2 - Microsoft.EntityFrameworkCore.Tools - 5.0.0-preview.3.20174.2 - Microsoft.EntityFrameworkCore.SqlServer - 5.0.0-preview.3.20174.2 - dotnet-ef - 5.0.0-preview.3.20174.2 - Microsoft.EntityFrameworkCore - 5.0.0-preview.3.20174.2 - Microsoft.EntityFrameworkCore.InMemory - 5.0.0-preview.3.20174.2 - Microsoft.EntityFrameworkCore.Relational - 5.0.0-preview.3.20174.2 - Microsoft.EntityFrameworkCore.Sqlite - 5.0.0-preview.3.20174.2 * Update dependencies from https://github.com/dotnet/efcore build 20200324.3 - Microsoft.EntityFrameworkCore.Tools - 5.0.0-preview.3.20174.3 - Microsoft.EntityFrameworkCore.SqlServer - 5.0.0-preview.3.20174.3 - dotnet-ef - 5.0.0-preview.3.20174.3 - Microsoft.EntityFrameworkCore - 5.0.0-preview.3.20174.3 - Microsoft.EntityFrameworkCore.InMemory - 5.0.0-preview.3.20174.3 - Microsoft.EntityFrameworkCore.Relational - 5.0.0-preview.3.20174.3 - Microsoft.EntityFrameworkCore.Sqlite - 5.0.0-preview.3.20174.3 * Update dependencies from https://github.com/dotnet/efcore build 20200324.4 - Microsoft.EntityFrameworkCore.Tools - 5.0.0-preview.3.20174.4 - Microsoft.EntityFrameworkCore.SqlServer - 5.0.0-preview.3.20174.4 - dotnet-ef - 5.0.0-preview.3.20174.4 - Microsoft.EntityFrameworkCore - 5.0.0-preview.3.20174.4 - Microsoft.EntityFrameworkCore.InMemory - 5.0.0-preview.3.20174.4 - Microsoft.EntityFrameworkCore.Relational - 5.0.0-preview.3.20174.4 - Microsoft.EntityFrameworkCore.Sqlite - 5.0.0-preview.3.20174.4 * Update dependencies from https://github.com/dotnet/efcore build 20200324.5 - Microsoft.EntityFrameworkCore.Tools - 5.0.0-preview.3.20174.5 - Microsoft.EntityFrameworkCore.SqlServer - 5.0.0-preview.3.20174.5 - dotnet-ef - 5.0.0-preview.3.20174.5 - Microsoft.EntityFrameworkCore - 5.0.0-preview.3.20174.5 - Microsoft.EntityFrameworkCore.InMemory - 5.0.0-preview.3.20174.5 - Microsoft.EntityFrameworkCore.Relational - 5.0.0-preview.3.20174.5 - Microsoft.EntityFrameworkCore.Sqlite - 5.0.0-preview.3.20174.5 * React to EF Migrations breaking changes Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: AndriySvyryd <Andriy.Svyryd@microsoft.com>
This commit is contained in:
parent
196f4489e1
commit
30c5484424
|
|
@ -29,33 +29,33 @@
|
||||||
<Uri>https://github.com/dotnet/aspnetcore-tooling</Uri>
|
<Uri>https://github.com/dotnet/aspnetcore-tooling</Uri>
|
||||||
<Sha>dcbab464643d971765e77562d2d0854c6ae112f7</Sha>
|
<Sha>dcbab464643d971765e77562d2d0854c6ae112f7</Sha>
|
||||||
</Dependency>
|
</Dependency>
|
||||||
<Dependency Name="dotnet-ef" Version="5.0.0-preview.3.20170.2">
|
<Dependency Name="dotnet-ef" Version="5.0.0-preview.3.20174.5">
|
||||||
<Uri>https://github.com/dotnet/efcore</Uri>
|
<Uri>https://github.com/dotnet/efcore</Uri>
|
||||||
<Sha>ac4633559b117b92156d75f07b7ef81dc920b4fd</Sha>
|
<Sha>21b9a35db594f7a383e855f922babbe54b3d38c5</Sha>
|
||||||
</Dependency>
|
</Dependency>
|
||||||
<Dependency Name="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.0-preview.3.20170.2">
|
<Dependency Name="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.0-preview.3.20174.5">
|
||||||
<Uri>https://github.com/dotnet/efcore</Uri>
|
<Uri>https://github.com/dotnet/efcore</Uri>
|
||||||
<Sha>ac4633559b117b92156d75f07b7ef81dc920b4fd</Sha>
|
<Sha>21b9a35db594f7a383e855f922babbe54b3d38c5</Sha>
|
||||||
</Dependency>
|
</Dependency>
|
||||||
<Dependency Name="Microsoft.EntityFrameworkCore.Relational" Version="5.0.0-preview.3.20170.2">
|
<Dependency Name="Microsoft.EntityFrameworkCore.Relational" Version="5.0.0-preview.3.20174.5">
|
||||||
<Uri>https://github.com/dotnet/efcore</Uri>
|
<Uri>https://github.com/dotnet/efcore</Uri>
|
||||||
<Sha>ac4633559b117b92156d75f07b7ef81dc920b4fd</Sha>
|
<Sha>21b9a35db594f7a383e855f922babbe54b3d38c5</Sha>
|
||||||
</Dependency>
|
</Dependency>
|
||||||
<Dependency Name="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.0-preview.3.20170.2">
|
<Dependency Name="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.0-preview.3.20174.5">
|
||||||
<Uri>https://github.com/dotnet/efcore</Uri>
|
<Uri>https://github.com/dotnet/efcore</Uri>
|
||||||
<Sha>ac4633559b117b92156d75f07b7ef81dc920b4fd</Sha>
|
<Sha>21b9a35db594f7a383e855f922babbe54b3d38c5</Sha>
|
||||||
</Dependency>
|
</Dependency>
|
||||||
<Dependency Name="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0-preview.3.20170.2">
|
<Dependency Name="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0-preview.3.20174.5">
|
||||||
<Uri>https://github.com/dotnet/efcore</Uri>
|
<Uri>https://github.com/dotnet/efcore</Uri>
|
||||||
<Sha>ac4633559b117b92156d75f07b7ef81dc920b4fd</Sha>
|
<Sha>21b9a35db594f7a383e855f922babbe54b3d38c5</Sha>
|
||||||
</Dependency>
|
</Dependency>
|
||||||
<Dependency Name="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0-preview.3.20170.2">
|
<Dependency Name="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0-preview.3.20174.5">
|
||||||
<Uri>https://github.com/dotnet/efcore</Uri>
|
<Uri>https://github.com/dotnet/efcore</Uri>
|
||||||
<Sha>ac4633559b117b92156d75f07b7ef81dc920b4fd</Sha>
|
<Sha>21b9a35db594f7a383e855f922babbe54b3d38c5</Sha>
|
||||||
</Dependency>
|
</Dependency>
|
||||||
<Dependency Name="Microsoft.EntityFrameworkCore" Version="5.0.0-preview.3.20170.2">
|
<Dependency Name="Microsoft.EntityFrameworkCore" Version="5.0.0-preview.3.20174.5">
|
||||||
<Uri>https://github.com/dotnet/efcore</Uri>
|
<Uri>https://github.com/dotnet/efcore</Uri>
|
||||||
<Sha>ac4633559b117b92156d75f07b7ef81dc920b4fd</Sha>
|
<Sha>21b9a35db594f7a383e855f922babbe54b3d38c5</Sha>
|
||||||
</Dependency>
|
</Dependency>
|
||||||
<Dependency Name="Microsoft.AspNetCore.Analyzer.Testing" Version="5.0.0-preview.3.20170.1" CoherentParentDependency="Microsoft.AspNetCore.Razor.Language">
|
<Dependency Name="Microsoft.AspNetCore.Analyzer.Testing" Version="5.0.0-preview.3.20170.1" CoherentParentDependency="Microsoft.AspNetCore.Razor.Language">
|
||||||
<Uri>https://github.com/dotnet/extensions</Uri>
|
<Uri>https://github.com/dotnet/extensions</Uri>
|
||||||
|
|
|
||||||
|
|
@ -139,13 +139,13 @@
|
||||||
<MicrosoftExtensionsPrimitivesPackageVersion>5.0.0-preview.3.20170.1</MicrosoftExtensionsPrimitivesPackageVersion>
|
<MicrosoftExtensionsPrimitivesPackageVersion>5.0.0-preview.3.20170.1</MicrosoftExtensionsPrimitivesPackageVersion>
|
||||||
<MicrosoftInternalExtensionsRefsPackageVersion>5.0.0-preview.3.20170.1</MicrosoftInternalExtensionsRefsPackageVersion>
|
<MicrosoftInternalExtensionsRefsPackageVersion>5.0.0-preview.3.20170.1</MicrosoftInternalExtensionsRefsPackageVersion>
|
||||||
<!-- Packages from dotnet/efcore -->
|
<!-- Packages from dotnet/efcore -->
|
||||||
<dotnetefPackageVersion>5.0.0-preview.3.20170.2</dotnetefPackageVersion>
|
<dotnetefPackageVersion>5.0.0-preview.3.20174.5</dotnetefPackageVersion>
|
||||||
<MicrosoftEntityFrameworkCoreInMemoryPackageVersion>5.0.0-preview.3.20170.2</MicrosoftEntityFrameworkCoreInMemoryPackageVersion>
|
<MicrosoftEntityFrameworkCoreInMemoryPackageVersion>5.0.0-preview.3.20174.5</MicrosoftEntityFrameworkCoreInMemoryPackageVersion>
|
||||||
<MicrosoftEntityFrameworkCoreRelationalPackageVersion>5.0.0-preview.3.20170.2</MicrosoftEntityFrameworkCoreRelationalPackageVersion>
|
<MicrosoftEntityFrameworkCoreRelationalPackageVersion>5.0.0-preview.3.20174.5</MicrosoftEntityFrameworkCoreRelationalPackageVersion>
|
||||||
<MicrosoftEntityFrameworkCoreSqlitePackageVersion>5.0.0-preview.3.20170.2</MicrosoftEntityFrameworkCoreSqlitePackageVersion>
|
<MicrosoftEntityFrameworkCoreSqlitePackageVersion>5.0.0-preview.3.20174.5</MicrosoftEntityFrameworkCoreSqlitePackageVersion>
|
||||||
<MicrosoftEntityFrameworkCoreSqlServerPackageVersion>5.0.0-preview.3.20170.2</MicrosoftEntityFrameworkCoreSqlServerPackageVersion>
|
<MicrosoftEntityFrameworkCoreSqlServerPackageVersion>5.0.0-preview.3.20174.5</MicrosoftEntityFrameworkCoreSqlServerPackageVersion>
|
||||||
<MicrosoftEntityFrameworkCoreToolsPackageVersion>5.0.0-preview.3.20170.2</MicrosoftEntityFrameworkCoreToolsPackageVersion>
|
<MicrosoftEntityFrameworkCoreToolsPackageVersion>5.0.0-preview.3.20174.5</MicrosoftEntityFrameworkCoreToolsPackageVersion>
|
||||||
<MicrosoftEntityFrameworkCorePackageVersion>5.0.0-preview.3.20170.2</MicrosoftEntityFrameworkCorePackageVersion>
|
<MicrosoftEntityFrameworkCorePackageVersion>5.0.0-preview.3.20174.5</MicrosoftEntityFrameworkCorePackageVersion>
|
||||||
<!-- Packages from dotnet/aspnetcore-tooling -->
|
<!-- Packages from dotnet/aspnetcore-tooling -->
|
||||||
<MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion>5.0.0-preview.3.20170.3</MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion>
|
<MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion>5.0.0-preview.3.20170.3</MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion>
|
||||||
<MicrosoftAspNetCoreRazorLanguagePackageVersion>5.0.0-preview.3.20170.3</MicrosoftAspNetCoreRazorLanguagePackageVersion>
|
<MicrosoftAspNetCoreRazorLanguagePackageVersion>5.0.0-preview.3.20170.3</MicrosoftAspNetCoreRazorLanguagePackageVersion>
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@ using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Conventions;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Storage;
|
using Microsoft.EntityFrameworkCore.Storage;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
@ -138,13 +141,36 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
|
||||||
var migrationsAssembly = context.GetService<IMigrationsAssembly>();
|
var migrationsAssembly = context.GetService<IMigrationsAssembly>();
|
||||||
var modelDiffer = context.GetService<IMigrationsModelDiffer>();
|
var modelDiffer = context.GetService<IMigrationsModelDiffer>();
|
||||||
|
|
||||||
|
var snapshotModel = migrationsAssembly.ModelSnapshot?.Model;
|
||||||
|
if (snapshotModel is IConventionModel conventionModel)
|
||||||
|
{
|
||||||
|
var conventionSet = context.GetService<IConventionSetBuilder>().CreateConventionSet();
|
||||||
|
|
||||||
|
var typeMappingConvention = conventionSet.ModelFinalizingConventions.OfType<TypeMappingConvention>().FirstOrDefault();
|
||||||
|
if (typeMappingConvention != null)
|
||||||
|
{
|
||||||
|
typeMappingConvention.ProcessModelFinalizing(conventionModel.Builder, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
var relationalModelConvention = conventionSet.ModelFinalizedConventions.OfType<RelationalModelConvention>().FirstOrDefault();
|
||||||
|
if (relationalModelConvention != null)
|
||||||
|
{
|
||||||
|
snapshotModel = relationalModelConvention.ProcessModelFinalized(conventionModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (snapshotModel is IMutableModel mutableModel)
|
||||||
|
{
|
||||||
|
snapshotModel = mutableModel.FinalizeModel();
|
||||||
|
}
|
||||||
|
|
||||||
// HasDifferences will return true if there is no model snapshot, but if there is an existing database
|
// HasDifferences will return true if there is no model snapshot, but if there is an existing database
|
||||||
// and no model snapshot then we don't want to show the error page since they are most likely targeting
|
// and no model snapshot then we don't want to show the error page since they are most likely targeting
|
||||||
// and existing database and have just misconfigured their model
|
// and existing database and have just misconfigured their model
|
||||||
|
|
||||||
var pendingModelChanges
|
var pendingModelChanges
|
||||||
= (!databaseExists || migrationsAssembly.ModelSnapshot != null)
|
= (!databaseExists || migrationsAssembly.ModelSnapshot != null)
|
||||||
&& modelDiffer.HasDifferences(migrationsAssembly.ModelSnapshot?.Model, context.Model);
|
&& modelDiffer.HasDifferences(snapshotModel?.GetRelationalModel(), context.Model.GetRelationalModel());
|
||||||
|
|
||||||
var pendingMigrations
|
var pendingMigrations
|
||||||
= (databaseExists
|
= (databaseExists
|
||||||
|
|
|
||||||
|
|
@ -21,25 +21,29 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests
|
||||||
return new BloggingContextWithMigrations(options);
|
return new BloggingContextWithMigrations(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void BuildSnapshotModel(ModelBuilder builder)
|
||||||
|
{
|
||||||
|
builder.Entity("Blogging.Models.Blog", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("BlogId").ValueGeneratedOnAdd();
|
||||||
|
b.Property<string>("Name");
|
||||||
|
b.HasKey("BlogId");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
[DbContext(typeof(BloggingContextWithMigrations))]
|
[DbContext(typeof(BloggingContextWithMigrations))]
|
||||||
public class BloggingContextWithMigrationsModelSnapshot : ModelSnapshot
|
public class BloggingContextWithMigrationsModelSnapshot : ModelSnapshot
|
||||||
{
|
{
|
||||||
protected override void BuildModel(ModelBuilder builder)
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
{
|
=> BuildSnapshotModel(modelBuilder);
|
||||||
builder.Entity("Blogging.Models.Blog", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("BlogId").ValueGeneratedOnAdd();
|
|
||||||
b.Property<string>("Name");
|
|
||||||
b.HasKey("BlogId");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[DbContext(typeof(BloggingContextWithMigrations))]
|
[DbContext(typeof(BloggingContextWithMigrations))]
|
||||||
[Migration("111111111111111_MigrationOne")]
|
[Migration("111111111111111_MigrationOne")]
|
||||||
public class MigrationOne : Migration
|
public class MigrationOne : Migration
|
||||||
{
|
{
|
||||||
public override IModel TargetModel => new BloggingContextWithMigrationsModelSnapshot().Model;
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
=> BuildSnapshotModel(modelBuilder);
|
||||||
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
|
|
@ -62,7 +66,8 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests
|
||||||
[Migration("222222222222222_MigrationTwo")]
|
[Migration("222222222222222_MigrationTwo")]
|
||||||
public class MigrationTwo : Migration
|
public class MigrationTwo : Migration
|
||||||
{
|
{
|
||||||
public override IModel TargetModel => new BloggingContextWithMigrationsModelSnapshot().Model;
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
=> BuildSnapshotModel(modelBuilder);
|
||||||
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{ }
|
{ }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue