Skip to content

[master] Update dependencies from dotnet/efcore #20107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,33 @@
<Uri>https://github.com/dotnet/aspnetcore-tooling</Uri>
<Sha>dcbab464643d971765e77562d2d0854c6ae112f7</Sha>
</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>
<Sha>ac4633559b117b92156d75f07b7ef81dc920b4fd</Sha>
<Sha>21b9a35db594f7a383e855f922babbe54b3d38c5</Sha>
</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>
<Sha>ac4633559b117b92156d75f07b7ef81dc920b4fd</Sha>
<Sha>21b9a35db594f7a383e855f922babbe54b3d38c5</Sha>
</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>
<Sha>ac4633559b117b92156d75f07b7ef81dc920b4fd</Sha>
<Sha>21b9a35db594f7a383e855f922babbe54b3d38c5</Sha>
</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>
<Sha>ac4633559b117b92156d75f07b7ef81dc920b4fd</Sha>
<Sha>21b9a35db594f7a383e855f922babbe54b3d38c5</Sha>
</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>
<Sha>ac4633559b117b92156d75f07b7ef81dc920b4fd</Sha>
<Sha>21b9a35db594f7a383e855f922babbe54b3d38c5</Sha>
</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>
<Sha>ac4633559b117b92156d75f07b7ef81dc920b4fd</Sha>
<Sha>21b9a35db594f7a383e855f922babbe54b3d38c5</Sha>
</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>
<Sha>ac4633559b117b92156d75f07b7ef81dc920b4fd</Sha>
<Sha>21b9a35db594f7a383e855f922babbe54b3d38c5</Sha>
</Dependency>
<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>
Expand Down
14 changes: 7 additions & 7 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@
<MicrosoftExtensionsPrimitivesPackageVersion>5.0.0-preview.3.20170.1</MicrosoftExtensionsPrimitivesPackageVersion>
<MicrosoftInternalExtensionsRefsPackageVersion>5.0.0-preview.3.20170.1</MicrosoftInternalExtensionsRefsPackageVersion>
<!-- Packages from dotnet/efcore -->
<dotnetefPackageVersion>5.0.0-preview.3.20170.2</dotnetefPackageVersion>
<MicrosoftEntityFrameworkCoreInMemoryPackageVersion>5.0.0-preview.3.20170.2</MicrosoftEntityFrameworkCoreInMemoryPackageVersion>
<MicrosoftEntityFrameworkCoreRelationalPackageVersion>5.0.0-preview.3.20170.2</MicrosoftEntityFrameworkCoreRelationalPackageVersion>
<MicrosoftEntityFrameworkCoreSqlitePackageVersion>5.0.0-preview.3.20170.2</MicrosoftEntityFrameworkCoreSqlitePackageVersion>
<MicrosoftEntityFrameworkCoreSqlServerPackageVersion>5.0.0-preview.3.20170.2</MicrosoftEntityFrameworkCoreSqlServerPackageVersion>
<MicrosoftEntityFrameworkCoreToolsPackageVersion>5.0.0-preview.3.20170.2</MicrosoftEntityFrameworkCoreToolsPackageVersion>
<MicrosoftEntityFrameworkCorePackageVersion>5.0.0-preview.3.20170.2</MicrosoftEntityFrameworkCorePackageVersion>
<dotnetefPackageVersion>5.0.0-preview.3.20174.5</dotnetefPackageVersion>
<MicrosoftEntityFrameworkCoreInMemoryPackageVersion>5.0.0-preview.3.20174.5</MicrosoftEntityFrameworkCoreInMemoryPackageVersion>
<MicrosoftEntityFrameworkCoreRelationalPackageVersion>5.0.0-preview.3.20174.5</MicrosoftEntityFrameworkCoreRelationalPackageVersion>
<MicrosoftEntityFrameworkCoreSqlitePackageVersion>5.0.0-preview.3.20174.5</MicrosoftEntityFrameworkCoreSqlitePackageVersion>
<MicrosoftEntityFrameworkCoreSqlServerPackageVersion>5.0.0-preview.3.20174.5</MicrosoftEntityFrameworkCoreSqlServerPackageVersion>
<MicrosoftEntityFrameworkCoreToolsPackageVersion>5.0.0-preview.3.20174.5</MicrosoftEntityFrameworkCoreToolsPackageVersion>
<MicrosoftEntityFrameworkCorePackageVersion>5.0.0-preview.3.20174.5</MicrosoftEntityFrameworkCorePackageVersion>
<!-- Packages from dotnet/aspnetcore-tooling -->
<MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion>5.0.0-preview.3.20170.3</MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion>
<MicrosoftAspNetCoreRazorLanguagePackageVersion>5.0.0-preview.3.20170.3</MicrosoftAspNetCoreRazorLanguagePackageVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
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.Storage;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -138,13 +141,36 @@ public virtual async Task Invoke(HttpContext httpContext)
var migrationsAssembly = context.GetService<IMigrationsAssembly>();
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
// 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

var pendingModelChanges
= (!databaseExists || migrationsAssembly.ModelSnapshot != null)
&& modelDiffer.HasDifferences(migrationsAssembly.ModelSnapshot?.Model, context.Model);
&& modelDiffer.HasDifferences(snapshotModel?.GetRelationalModel(), context.Model.GetRelationalModel());

var pendingMigrations
= (databaseExists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,29 @@ public static BloggingContextWithMigrations CreateWithoutExternalServiceProvider
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))]
public class BloggingContextWithMigrationsModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder builder)
{
builder.Entity("Blogging.Models.Blog", b =>
{
b.Property<int>("BlogId").ValueGeneratedOnAdd();
b.Property<string>("Name");
b.HasKey("BlogId");
});
}
protected override void BuildModel(ModelBuilder modelBuilder)
=> BuildSnapshotModel(modelBuilder);
}

[DbContext(typeof(BloggingContextWithMigrations))]
[Migration("111111111111111_MigrationOne")]
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)
{
Expand All @@ -62,7 +66,8 @@ protected override void Down(MigrationBuilder migrationBuilder)
[Migration("222222222222222_MigrationTwo")]
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)
{ }
Expand Down