本文整理汇总了C#中System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.ToTable方法的典型用法代码示例。如果您正苦于以下问题:C# EntityTypeConfiguration.ToTable方法的具体用法?C# EntityTypeConfiguration.ToTable怎么用?C# EntityTypeConfiguration.ToTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration
的用法示例。
在下文中一共展示了EntityTypeConfiguration.ToTable方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply_should_not_set_table_name_when_already_set
public void Apply_should_not_set_table_name_when_already_set()
{
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
entityTypeConfiguration.ToTable("Bar");
new TableAttributeConvention.TableAttributeConventionImpl()
.Apply(new MockType(), entityTypeConfiguration, new TableAttribute("Foo"));
Assert.Equal("Bar", entityTypeConfiguration.GetTableName().Name);
}
示例2: ToTable_with_schema_is_noop_when_set
public void ToTable_with_schema_is_noop_when_set()
{
var type = new MockType();
var innerConfig = new EntityTypeConfiguration(type);
innerConfig.ToTable("Table1", "Schema1");
var config = new LightweightEntityConfiguration(type, () => innerConfig);
config.ToTable("Table2", "Schema2");
Assert.Equal("Table1", innerConfig.TableName);
Assert.Equal("Schema1", innerConfig.SchemaName);
}
示例3: ToTable_is_noop_when_set
public void ToTable_is_noop_when_set()
{
var type = new MockType();
var innerConfig = new EntityTypeConfiguration(type);
innerConfig.ToTable("Table1");
var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration());
config.ToTable("Table2");
Assert.Equal("Table1", innerConfig.TableName);
}
示例4: Apply_should_match_key_that_is_an_fk_used_in_table_splitting
public void Apply_should_match_key_that_is_an_fk_used_in_table_splitting()
{
var model = new EdmModel(DataSpace.CSpace);
var entityType = new EntityType("E", "N", DataSpace.CSpace);
var property = EdmProperty.CreatePrimitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int64));
entityType.AddKeyMember(property);
var targetConfig = new EntityTypeConfiguration(typeof(object));
targetConfig.ToTable("SharedTable");
entityType.GetMetadataProperties().SetConfiguration(targetConfig);
var sourceEntityType = new EntityType("E", "N", DataSpace.CSpace);
var sourceConfig = new EntityTypeConfiguration(typeof(object));
sourceConfig.ToTable("SharedTable");
sourceEntityType.GetMetadataProperties().SetConfiguration(sourceConfig);
var associationType
= model.AddAssociationType(
"A", sourceEntityType, RelationshipMultiplicity.One,
entityType, RelationshipMultiplicity.One);
associationType.Constraint
= new ReferentialConstraint(
associationType.SourceEnd,
associationType.TargetEnd,
new[] { property },
new[] { property });
(new StoreGeneratedIdentityKeyConvention())
.Apply(entityType, new DbModel(model, null));
Assert.Equal(
StoreGeneratedPattern.Identity,
entityType.KeyProperties.Single().GetStoreGeneratedPattern());
}
示例5: Apply_should_match_key_that_is_an_fk_used_in_table_splitting
public void Apply_should_match_key_that_is_an_fk_used_in_table_splitting()
{
var model = new EdmModel().Initialize();
var entityType = new EdmEntityType();
var property = new EdmProperty().AsPrimitive();
property.PropertyType.EdmType = EdmPrimitiveType.Int64;
entityType.DeclaredKeyProperties.Add(property);
var targetConfig = new EntityTypeConfiguration(typeof(object));
targetConfig.ToTable("SharedTable");
entityType.SetConfiguration(targetConfig);
var sourceEntityType = new EdmEntityType();
var sourceConfig = new EntityTypeConfiguration(typeof(object));
sourceConfig.ToTable("SharedTable");
sourceEntityType.SetConfiguration(sourceConfig);
var associationType
= model.AddAssociationType(
"A", sourceEntityType, EdmAssociationEndKind.Required,
entityType, EdmAssociationEndKind.Required);
associationType.Constraint = new EdmAssociationConstraint();
associationType.Constraint.DependentProperties.Add(property);
((IEdmConvention<EdmEntityType>)new StoreGeneratedIdentityKeyConvention())
.Apply(entityType, model);
Assert.Equal(
DbStoreGeneratedPattern.Identity,
entityType.DeclaredKeyProperties.Single().GetStoreGeneratedPattern());
}
示例6: ToTable_overwrites_existing_name
public void ToTable_overwrites_existing_name()
{
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
entityTypeConfiguration.ToTable("Foo");
entityTypeConfiguration.ToTable("Bar");
Assert.Equal("Bar", entityTypeConfiguration.GetTableName().Name);
}
示例7: GetTableName_returns_current_TableName
public void GetTableName_returns_current_TableName()
{
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
Assert.Equal(null, entityTypeConfiguration.GetTableName());
entityTypeConfiguration.ToTable("Foo");
Assert.Equal("Foo", entityTypeConfiguration.GetTableName().Name);
}
示例8: SchemaName_returns_current_SchemaName
public void SchemaName_returns_current_SchemaName()
{
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
Assert.Equal(null, entityTypeConfiguration.SchemaName);
entityTypeConfiguration.ToTable("Foo", "Bar");
Assert.Equal("Bar", entityTypeConfiguration.SchemaName);
}
示例9: Can_get_and_set_table_name
public void Can_get_and_set_table_name()
{
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
entityTypeConfiguration.ToTable("Foo");
Assert.Equal("Foo", entityTypeConfiguration.GetTableName().Name);
}