React to EF: changes in ModelSnapshot

This commit is contained in:
Smit Patel 2015-05-14 14:01:06 -07:00
parent 6676651e54
commit c6c5c94971
3 changed files with 18 additions and 34 deletions

View File

@ -4,8 +4,6 @@
using System;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Metadata.ModelConventions;
using Microsoft.Data.Entity.Relational.Migrations;
using Microsoft.Data.Entity.Relational.Migrations.Builders;
using Microsoft.Data.Entity.Relational.Migrations.Infrastructure;
@ -31,22 +29,15 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
[ContextType(typeof(BloggingContextWithMigrations))]
public class BloggingContextWithMigrationsModelSnapshot : ModelSnapshot
{
public override IModel Model
public override void BuildModel(ModelBuilder builder)
{
get
builder.Entity("Blogging.Models.Blog", b =>
{
var builder = new ModelBuilder(new ConventionSet());
builder.Entity("Blogging.Models.Blog", b =>
{
b.Property<int>("BlogId");
b.Property<int>("BlogId").GenerateValueOnAdd();
b.Property<string>("Name");
b.Key("BlogId");
});
return builder.Model;
}
b.Property<int>("BlogId");
b.Property<int>("BlogId").GenerateValueOnAdd();
b.Property<string>("Name");
b.Key("BlogId");
});
}
}
@ -63,9 +54,9 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
get { return CurrentProductVersion; }
}
public override IModel Target
public override void BuildTargetModel(ModelBuilder modelBuilder)
{
get { return new BloggingContextWithMigrationsModelSnapshot().Model; }
new BloggingContextWithMigrationsModelSnapshot().BuildModel(modelBuilder);
}
public override void Up(MigrationBuilder migrationBuilder)
@ -98,9 +89,9 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
get { return CurrentProductVersion; }
}
public override IModel Target
public override void BuildTargetModel(ModelBuilder modelBuilder)
{
get { return new BloggingContextWithMigrationsModelSnapshot().Model; }
new BloggingContextWithMigrationsModelSnapshot().BuildModel(modelBuilder);
}
public override void Up(MigrationBuilder migrationBuilder)

View File

@ -4,8 +4,6 @@
using System;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Metadata.ModelConventions;
using Microsoft.Data.Entity.Relational.Migrations;
using Microsoft.Data.Entity.Relational.Migrations.Builders;
using Microsoft.Data.Entity.Relational.Migrations.Infrastructure;
@ -21,9 +19,8 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
[ContextType(typeof(BloggingContextWithPendingModelChanges))]
public class BloggingModelSnapshot : ModelSnapshot
{
public override IModel Model
public override void BuildModel(ModelBuilder modelBuilder)
{
get { return new ModelBuilder(new ConventionSet()).Model; }
}
}
@ -40,9 +37,8 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
get { return CurrentProductVersion; }
}
public override IModel Target
public override void BuildTargetModel(ModelBuilder modelBuilder)
{
get { return new ModelBuilder(new ConventionSet()).Model; }
}
public override void Up(MigrationBuilder migrationBuilder)

View File

@ -3,12 +3,12 @@
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Relational.Migrations;
using Microsoft.Data.Entity.Relational.Migrations.Builders;
using Microsoft.Data.Entity.Relational.Migrations.Infrastructure;
using System;
namespace Microsoft.AspNet.Diagnostics.Entity.Tests
{
public class BloggingContextWithSnapshotThatThrows : BloggingContext
@ -20,12 +20,9 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
[ContextType(typeof(BloggingContextWithSnapshotThatThrows))]
public class BloggingContextWithSnapshotThatThrowsModelSnapshot : ModelSnapshot
{
public override IModel Model
public override void BuildModel(ModelBuilder modelBuilder)
{
get
{
throw new Exception("Welcome to the invalid snapshot!");
}
throw new Exception("Welcome to the invalid snapshot!");
}
}
@ -42,9 +39,9 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
get { return CurrentProductVersion; }
}
public override IModel Target
public override void BuildTargetModel(ModelBuilder modelBuilder)
{
get { return new BloggingContextWithSnapshotThatThrowsModelSnapshot().Model; }
new BloggingContextWithSnapshotThatThrowsModelSnapshot().BuildModel(modelBuilder);
}
public override void Up(MigrationBuilder migrationBuilder)