本文整理汇总了C#中System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer类的典型用法代码示例。如果您正苦于以下问题:C# EdmModelDiffer类的具体用法?C# EdmModelDiffer怎么用?C# EdmModelDiffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdmModelDiffer类属于System.Data.Entity.Migrations.Infrastructure命名空间,在下文中一共展示了EdmModelDiffer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: System_operations_are_included_when_requested
public void System_operations_are_included_when_requested()
{
var modelBuilder = new DbModelBuilder();
var model1 = modelBuilder.Build(ProviderInfo).GetModel();
modelBuilder = new DbModelBuilder();
var model2 = modelBuilder.Build(ProviderInfo).GetModel();
new HistoryRepository(ConnectionString, ProviderFactory).AppendHistoryModel(model2, ProviderInfo);
var operations = new EdmModelDiffer().Diff(model1, model2, includeSystemOperations: true);
var createTableOperation
= operations.OfType<CreateTableOperation>().Single();
Assert.True(createTableOperation.IsSystem);
operations = new EdmModelDiffer().Diff(model2, model1, includeSystemOperations: true);
var dropTableOperation
= operations.OfType<DropTableOperation>().Single();
Assert.True(dropTableOperation.IsSystem);
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:26,代码来源:EdmModelDifferTests.cs
示例2: System_operations_are_ignored_by_default
public void System_operations_are_ignored_by_default()
{
var modelBuilder = new DbModelBuilder();
var model1 = modelBuilder.Build(ProviderInfo).GetModel();
modelBuilder = new DbModelBuilder();
var model2 = modelBuilder.Build(ProviderInfo).GetModel();
new HistoryRepository(ConnectionString, ProviderFactory).AppendHistoryModel(model2, ProviderInfo);
var operations = new EdmModelDiffer().Diff(model1, model2);
Assert.Equal(0, operations.Count());
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:16,代码来源:EdmModelDifferTests.cs
示例3: Can_diff_identical_models_at_different_edm_versions_and_no_diffs_produced
public void Can_diff_identical_models_at_different_edm_versions_and_no_diffs_produced()
{
var modelBuilder = new DbModelBuilder(DbModelBuilderVersion.V4_1);
modelBuilder.Entity<OrderLine>();
var model1 = modelBuilder.Build(ProviderInfo);
modelBuilder = new DbModelBuilder(DbModelBuilderVersion.V5_0);
modelBuilder.Entity<OrderLine>();
var model2 = modelBuilder.Build(ProviderInfo);
var operations = new EdmModelDiffer().Diff(
model1.GetModel(), model2.GetModel());
Assert.Equal(0, operations.Count());
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:19,代码来源:EdmModelDifferTests.cs
示例4: Should_generate_add_column_operation_when_shared_pk_fk_moved_to_ia
public void Should_generate_add_column_operation_when_shared_pk_fk_moved_to_ia()
{
var modelBuilder = new DbModelBuilder();
modelBuilder.Entity<ArubaRun>();
modelBuilder.Entity<ArubaTask>().HasKey(k => new { k.Id, k.Name });
var model1 = modelBuilder.Build(ProviderInfo);
modelBuilder.Entity<ArubaRun>().HasMany(r => r.Tasks).WithRequired().Map(m => { });
var model2 = modelBuilder.Build(ProviderInfo);
var operations
= new EdmModelDiffer().Diff(model1.GetModel(), model2.GetModel());
Assert.Equal(5, operations.Count());
Assert.True(operations.Any(o => o is AddColumnOperation));
}
开发者ID:,项目名称:,代码行数:19,代码来源:
示例5: Bug_47549_crash_when_many_to_many_end_renamed_in_ospace
public void Bug_47549_crash_when_many_to_many_end_renamed_in_ospace()
{
var modelBuilder = new DbModelBuilder();
modelBuilder.Entity<User>();
var model1 = modelBuilder.Build(ProviderInfo);
modelBuilder = new DbModelBuilder();
modelBuilder.Entity<User2>();
var model2 = modelBuilder.Build(ProviderInfo);
var operations = new EdmModelDiffer().Diff(
model1.GetModel(), model2.GetModel());
Assert.Equal(13, operations.Count());
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:19,代码来源:EdmModelDifferTests.cs
示例6: Can_detect_simple_table_rename
public void Can_detect_simple_table_rename()
{
var modelBuilder = new DbModelBuilder();
modelBuilder.Entity<MigrationsCustomer>();
var model1 = modelBuilder.Build(ProviderInfo);
modelBuilder.Entity<MigrationsCustomer>().ToTable("Customer");
var model2 = modelBuilder.Build(ProviderInfo);
var operations
= new EdmModelDiffer().Diff(model1.GetModel(), model2.GetModel());
var tableRename = (RenameTableOperation)operations.Single();
Assert.Equal("dbo.MigrationsCustomers", tableRename.Name);
Assert.Equal("Customer", tableRename.NewName);
}
开发者ID:jesusico83,项目名称:Telerik,代码行数:20,代码来源:EdmModelDifferTests.cs
示例7: Can_detect_renamed_many_to_many_table
public void Can_detect_renamed_many_to_many_table()
{
var modelBuilder = new DbModelBuilder();
modelBuilder.Entity<ManyManySelfRef>();
var model1 = modelBuilder.Build(ProviderInfo);
modelBuilder.Entity<ManyManySelfRef>().ToTable("Renamed");
var model2 = modelBuilder.Build(ProviderInfo);
var operations
= new EdmModelDiffer().Diff(model1.GetModel(), model2.GetModel());
var tableRename = (RenameTableOperation)operations.Single();
Assert.Equal("dbo.ManyManySelfRefs", tableRename.Name);
Assert.Equal("Renamed", tableRename.NewName);
}
开发者ID:jesusico83,项目名称:Telerik,代码行数:20,代码来源:EdmModelDifferTests.cs
示例8: Can_detect_changed_modification_functions
public void Can_detect_changed_modification_functions()
{
var commandTreeGenerator
= new ModificationCommandTreeGenerator(TestContext.CreateDynamicUpdateModel());
var targetModel = new TestContext_v2().GetModel();
var alterProcedureOperations
= new EdmModelDiffer()
.Diff(
new TestContext().GetModel(),
targetModel,
new Lazy<ModificationCommandTreeGenerator>(() => commandTreeGenerator),
new SqlServerMigrationSqlGenerator())
.OfType<AlterProcedureOperation>()
.ToList();
Assert.Equal(3, alterProcedureOperations.Count);
Assert.True(alterProcedureOperations.All(c => c.BodySql.Any()));
Assert.Equal(1, alterProcedureOperations.Count(c => c.Parameters.Any(p => p.Name == "key_for_update2")));
Assert.Equal(1, alterProcedureOperations.Count(c => c.Parameters.Any(p => p.Name == "affected_rows")));
}
开发者ID:,项目名称:,代码行数:22,代码来源:
示例9: Can_detect_added_modification_functions
public void Can_detect_added_modification_functions()
{
var modelBuilder = new DbModelBuilder();
var model1 = modelBuilder.Build(ProviderInfo);
var model2 = new TestContext();
var commandTreeGenerator
= new ModificationCommandTreeGenerator(TestContext.CreateDynamicUpdateModel());
var createProcedureOperations
= new EdmModelDiffer()
.Diff(
model1.GetModel(),
model2.GetModel(),
new Lazy<ModificationCommandTreeGenerator>(() => commandTreeGenerator),
new SqlServerMigrationSqlGenerator())
.OfType<CreateProcedureOperation>()
.ToList();
Assert.Equal(20, createProcedureOperations.Count);
Assert.True(createProcedureOperations.All(c => c.Name.Any()));
Assert.True(createProcedureOperations.All(c => c.BodySql.Any()));
}
开发者ID:,项目名称:,代码行数:25,代码来源:
示例10: Can_detect_added_tables
public void Can_detect_added_tables()
{
var modelBuilder = new DbModelBuilder();
var model1 = modelBuilder.Build(ProviderInfo);
modelBuilder.Entity<OrderLine>().ToTable("[foo.[]]].bar");
var model2 = modelBuilder.Build(ProviderInfo);
var operations = new EdmModelDiffer().Diff(
model1.GetModel(), model2.GetModel());
Assert.Equal(1, operations.Count());
var createTableOperation = operations.OfType<CreateTableOperation>().Single();
Assert.Equal("[foo.[]]].bar", createTableOperation.Name);
}
开发者ID:,项目名称:,代码行数:19,代码来源:
示例11: Can_populate_table_model_for_added_tables
public void Can_populate_table_model_for_added_tables()
{
var modelBuilder = new DbModelBuilder();
var model1 = modelBuilder.Build(ProviderInfo);
modelBuilder.Entity<MigrationsCustomer>();
var model2 = modelBuilder.Build(ProviderInfo);
var operations = new EdmModelDiffer().Diff(
model1.GetModel(), model2.GetModel());
Assert.Equal(2, operations.OfType<AddForeignKeyOperation>().Count());
var createTableOperation = operations.OfType<CreateTableOperation>().Single(t => t.Name == "ordering.Orders");
Assert.Equal(4, createTableOperation.Columns.Count());
Assert.Equal(1, createTableOperation.PrimaryKey.Columns.Count());
Assert.Equal("OrderId", createTableOperation.PrimaryKey.Columns.Single());
var customerIdColumn = createTableOperation.Columns.Single(c => c.Name == "MigrationsCustomer_Id");
Assert.Equal(PrimitiveTypeKind.Int32, customerIdColumn.Type);
Assert.Null(customerIdColumn.IsNullable);
var orderIdColumn = createTableOperation.Columns.Single(c => c.Name == "OrderId");
Assert.True(orderIdColumn.IsIdentity);
}
开发者ID:,项目名称:,代码行数:29,代码来源:
示例12: Should_not_detect_changed_foreign_keys_when_multiplicity
public void Should_not_detect_changed_foreign_keys_when_multiplicity()
{
var modelBuilder = new DbModelBuilder();
modelBuilder.Entity<Order>();
var model1 = modelBuilder.Build(ProviderInfo);
modelBuilder.Entity<Order>().HasMany(o => o.OrderLines).WithRequired();
var model2 = modelBuilder.Build(ProviderInfo);
var operations = new EdmModelDiffer().Diff(
model1.GetModel(), model2.GetModel());
Assert.Equal(0, operations.Count());
}
开发者ID:,项目名称:,代码行数:17,代码来源:
示例13: Should_not_detect_pk_change_when_pk_column_renamed
public void Should_not_detect_pk_change_when_pk_column_renamed()
{
var modelBuilder = new DbModelBuilder();
modelBuilder.Entity<OrderLine>();
var model1 = modelBuilder.Build(ProviderInfo);
modelBuilder = new DbModelBuilder();
modelBuilder.Entity<OrderLine>().Property(ol => ol.Id).HasColumnName("pk_ID");
var model2 = modelBuilder.Build(ProviderInfo);
var operations = new EdmModelDiffer().Diff(
model1.GetModel(), model2.GetModel());
Assert.Equal(1, operations.Count());
Assert.True(operations.Single() is RenameColumnOperation);
}
开发者ID:,项目名称:,代码行数:20,代码来源:
示例14: Can_detect_custom_store_type
public void Can_detect_custom_store_type()
{
var modelBuilder = new DbModelBuilder();
var model1 = modelBuilder.Build(ProviderInfo);
modelBuilder.Entity<OrderLine>();
var model2 = modelBuilder.Build(ProviderInfo);
var operations = new EdmModelDiffer().Diff(
model1.GetModel(), model2.GetModel());
var createTableOperation = operations.OfType<CreateTableOperation>().Single();
var column = createTableOperation.Columns.Single(c => c.Name == "Total");
Assert.Equal("money", column.StoreType);
createTableOperation.Columns.Except(new[] { column }).Each(c => Assert.Null(c.StoreType));
}
开发者ID:,项目名称:,代码行数:21,代码来源:
示例15: Can_detect_renamed_modification_functions_when_many_to_many
public void Can_detect_renamed_modification_functions_when_many_to_many()
{
var commandTreeGenerator
= new ModificationCommandTreeGenerator(TestContext.CreateDynamicUpdateModel());
var targetModel = new TestContext_v2b().GetModel();
var renameProcedureOperations
= new EdmModelDiffer()
.Diff(
new TestContext().GetModel(),
targetModel,
new Lazy<ModificationCommandTreeGenerator>(() => commandTreeGenerator),
new SqlServerMigrationSqlGenerator())
.OfType<RenameProcedureOperation>()
.ToList();
Assert.Equal(1, renameProcedureOperations.Count);
Assert.Equal(1, renameProcedureOperations.Count(c => c.NewName == "m2m_insert"));
}
开发者ID:,项目名称:,代码行数:20,代码来源:
示例16: Can_detect_timestamp_columns
public void Can_detect_timestamp_columns()
{
var modelBuilder = new DbModelBuilder();
modelBuilder.Entity<Order>();
var model2 = modelBuilder.Build(ProviderInfo);
modelBuilder = new DbModelBuilder();
modelBuilder.Entity<Order>().Ignore(o => o.Version);
var model1 = modelBuilder.Build(ProviderInfo);
var operations = new EdmModelDiffer().Diff(model1.GetModel(), model2.GetModel());
Assert.Equal(1, operations.Count());
var column = operations.OfType<AddColumnOperation>().Single().Column;
Assert.True(column.IsTimestamp);
}
开发者ID:,项目名称:,代码行数:22,代码来源:
示例17: Can_detect_dropped_columns
public void Can_detect_dropped_columns()
{
var modelBuilder = new DbModelBuilder();
modelBuilder.Entity<Order>();
var model1 = modelBuilder.Build(ProviderInfo);
modelBuilder = new DbModelBuilder();
modelBuilder.Entity<Order>().Ignore(o => o.Version);
var model2 = modelBuilder.Build(ProviderInfo);
var operations = new EdmModelDiffer().Diff(
model1.GetModel(), model2.GetModel());
Assert.Equal(1, operations.Count());
var dropColumnOperation = operations.OfType<DropColumnOperation>().Single();
Assert.Equal("ordering.Orders", dropColumnOperation.Table);
Assert.Equal("Version", dropColumnOperation.Name);
var inverse = (AddColumnOperation)dropColumnOperation.Inverse;
Assert.NotNull(inverse);
Assert.Equal("ordering.Orders", inverse.Table);
Assert.Equal("Version", inverse.Column.Name);
}
开发者ID:,项目名称:,代码行数:30,代码来源:
示例18: Cross_provider_diff_should_be_clean_when_same_model
public void Cross_provider_diff_should_be_clean_when_same_model()
{
var modelBuilder = new DbModelBuilder();
modelBuilder.Entity<Order>();
var model1 = modelBuilder.Build(new DbProviderInfo(DbProviders.Sql, "2008"));
modelBuilder = new DbModelBuilder();
modelBuilder.Entity<Order>();
var model2 = modelBuilder.Build(new DbProviderInfo(DbProviders.SqlCe, "4"));
var operations = new EdmModelDiffer().Diff(
model1.GetModel(), model2.GetModel());
Assert.Equal(0, operations.Count());
}
开发者ID:,项目名称:,代码行数:19,代码来源:
示例19: Can_detect_changed_primary_key_when_table_renamed
public void Can_detect_changed_primary_key_when_table_renamed()
{
var modelBuilder = new DbModelBuilder();
modelBuilder.Entity<OrderLine>();
var model1 = modelBuilder.Build(ProviderInfo);
modelBuilder = new DbModelBuilder();
modelBuilder.Entity<OrderLine>()
.HasKey(
ol => new
{
ol.Id,
ol.OrderId
})
.ToTable("tbl_OrderLines");
var model2 = modelBuilder.Build(ProviderInfo);
var operations = new EdmModelDiffer().Diff(
model1.GetModel(), model2.GetModel());
Assert.Equal(4, operations.Count());
var addPrimaryKeyOperation = operations.OfType<AddPrimaryKeyOperation>().Single();
Assert.Equal("dbo.tbl_OrderLines", addPrimaryKeyOperation.Table);
Assert.Equal("Id", addPrimaryKeyOperation.Columns.First());
Assert.Equal("OrderId", addPrimaryKeyOperation.Columns.Last());
var dropPrimaryKeyOperation = operations.OfType<DropPrimaryKeyOperation>().Single();
Assert.Equal("dbo.OrderLines", dropPrimaryKeyOperation.Table);
Assert.Equal("Id", dropPrimaryKeyOperation.Columns.Single());
}
开发者ID:,项目名称:,代码行数:37,代码来源:
示例20: Can_detect_changed_modification_functions_when_many_to_many
public void Can_detect_changed_modification_functions_when_many_to_many()
{
var commandTreeGenerator
= new ModificationCommandTreeGenerator(TestContext.CreateDynamicUpdateModel());
var targetModel = new TestContext_v2b().GetModel();
var alterProcedureOperations
= new EdmModelDiffer()
.Diff(
new TestContext().GetModel(),
targetModel,
new Lazy<ModificationCommandTreeGenerator>(() => commandTreeGenerator),
new SqlServerMigrationSqlGenerator())
.OfType<AlterProcedureOperation>()
.ToList();
Assert.Equal(2, alterProcedureOperations.Count);
Assert.Equal(1, alterProcedureOperations.Count(ap => ap.Parameters.Any(p => p.Name == "order_thing_id")));
Assert.Equal(1, alterProcedureOperations.Count(ap => ap.Parameters.Any(p => p.Name == "order_id")));
}
开发者ID:,项目名称:,代码行数:21,代码来源:
注:本文中的System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论