本文整理汇总了C#中InternalModelBuilder类的典型用法代码示例。如果您正苦于以下问题:C# InternalModelBuilder类的具体用法?C# InternalModelBuilder怎么用?C# InternalModelBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InternalModelBuilder类属于命名空间,在下文中一共展示了InternalModelBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
public virtual InternalModelBuilder Apply(InternalModelBuilder modelBuilder)
{
modelBuilder.Annotation(
SqlServerAnnotationNames.Prefix + SqlServerAnnotationNames.ValueGeneration,
SqlServerValueGenerationStrategy.Sequence.ToString(),
ConfigurationSource.Convention);
var sequence = new Sequence(Sequence.DefaultName) { Model = modelBuilder.Metadata };
modelBuilder.Annotation(
SqlServerAnnotationNames.Prefix + RelationalAnnotationNames.Sequence + sequence.Schema + "." + sequence.Name,
sequence.Serialize(),
ConfigurationSource.Convention
);
modelBuilder.Annotation(
SqlServerAnnotationNames.Prefix + SqlServerAnnotationNames.DefaultSequenceName,
sequence.Name,
ConfigurationSource.Convention);
modelBuilder.Annotation(
SqlServerAnnotationNames.Prefix + SqlServerAnnotationNames.DefaultSequenceSchema,
sequence.Schema,
ConfigurationSource.Convention);
return modelBuilder;
}
示例2: CreateInternalIndexBuilder
private InternalIndexBuilder CreateInternalIndexBuilder()
{
var modelBuilder = new InternalModelBuilder(new Model());
var entityBuilder = modelBuilder.Entity(typeof(Customer), ConfigurationSource.Explicit);
return entityBuilder.HasIndex(new[] { Customer.IdProperty, Customer.NameProperty }, ConfigurationSource.Explicit);
}
示例3: Apply
public virtual InternalModelBuilder Apply(InternalModelBuilder modelBuilder)
{
modelBuilder.RemoveEntityTypesUnreachableByNavigations(ConfigurationSource.DataAnnotation);
RemoveNavigationlessForeignKeys(modelBuilder);
return modelBuilder;
}
示例4: Throws_when_navigation_is_not_added_or_ignored
public void Throws_when_navigation_is_not_added_or_ignored()
{
var modelBuilder = new InternalModelBuilder(new Model(), new ConventionSet());
var entityTypeBuilder = modelBuilder.Entity(typeof(NavigationEntity), ConfigurationSource.Convention);
Assert.Equal(CoreStrings.NavigationNotAdded("Navigation", typeof(NavigationEntity).FullName),
Assert.Throws<InvalidOperationException>(() => new PropertyMappingValidationConvention().Apply(modelBuilder)).Message);
}
示例5: Does_not_throw_when_primitive_type_property_is_ignored
public virtual void Does_not_throw_when_primitive_type_property_is_ignored()
{
var modelBuilder = new InternalModelBuilder(new Model());
var entityTypeBuilder = modelBuilder.Entity(typeof(PrimitivePropertyEntity), ConfigurationSource.Convention);
entityTypeBuilder.Ignore("Property", ConfigurationSource.Convention);
CreateConvention().Apply(modelBuilder);
}
示例6: Throws_when_primitive_type_is_not_added_or_ignored
public void Throws_when_primitive_type_is_not_added_or_ignored()
{
var modelBuilder = new InternalModelBuilder(new Model(), new ConventionSet());
var entityTypeBuilder = modelBuilder.Entity(typeof(PrimitivePropertyEntity), ConfigurationSource.Convention);
Assert.Equal(CoreStrings.PropertyNotAdded("Property", typeof(PrimitivePropertyEntity).FullName),
Assert.Throws<InvalidOperationException>(() => new RelationalPropertyMappingValidationConvention(new TestRelationalTypeMapper()).Apply(modelBuilder)).Message);
}
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:8,代码来源:RelationalPropertyMappingValidationConventionTest.cs
示例7: Apply
public virtual InternalModelBuilder Apply(InternalModelBuilder modelBuilder)
{
modelBuilder.Annotation(
SqlServerAnnotationNames.Prefix + SqlServerAnnotationNames.ValueGeneration,
SqlServerValueGenerationStrategy.Sequence.ToString(),
ConfigurationSource.Convention);
return modelBuilder;
}
示例8: Does_not_throw_when_navigation_is_ignored
public void Does_not_throw_when_navigation_is_ignored()
{
var modelBuilder = new InternalModelBuilder(new Model(), new ConventionSet());
var entityTypeBuilder = modelBuilder.Entity(typeof(NavigationEntity), ConfigurationSource.Convention);
entityTypeBuilder.Ignore("Navigation", ConfigurationSource.Convention);
new PropertyMappingValidationConvention().Apply(modelBuilder);
}
示例9: Does_not_throw_when_primitive_type_is_added
public void Does_not_throw_when_primitive_type_is_added()
{
var modelBuilder = new InternalModelBuilder(new Model(), new ConventionSet());
var entityTypeBuilder = modelBuilder.Entity(typeof(PrimitivePropertyEntity), ConfigurationSource.Convention);
entityTypeBuilder.Property("Property", typeof(int), ConfigurationSource.Convention);
new PropertyMappingValidationConvention().Apply(modelBuilder);
}
示例10: Does_not_throw_when_primitive_type_is_ignored
public void Does_not_throw_when_primitive_type_is_ignored()
{
var modelBuilder = new InternalModelBuilder(new Model(), new ConventionSet());
var entityTypeBuilder = modelBuilder.Entity(typeof(PrimitivePropertyEntity), ConfigurationSource.Convention);
entityTypeBuilder.Ignore("Property", ConfigurationSource.Convention);
new RelationalPropertyMappingValidationConvention(new TestRelationalTypeMapper()).Apply(modelBuilder);
}
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:8,代码来源:RelationalPropertyMappingValidationConventionTest.cs
示例11: Throws_when_navigation_is_not_added_or_ignored
public virtual void Throws_when_navigation_is_not_added_or_ignored()
{
var modelBuilder = new InternalModelBuilder(new Model());
var entityTypeBuilder = modelBuilder.Entity(typeof(NavigationEntity), ConfigurationSource.Convention);
Assert.Equal(
CoreStrings.NavigationNotAdded(typeof(NavigationEntity).DisplayName(fullName: false), "Navigation", typeof(PrimitivePropertyEntity).Name),
Assert.Throws<InvalidOperationException>(() => CreateConvention().Apply(modelBuilder)).Message);
}
示例12: Throws_when_added_property_is_not_primitive_type
public void Throws_when_added_property_is_not_primitive_type()
{
var modelBuilder = new InternalModelBuilder(new Model(), new ConventionSet());
var entityTypeBuilder = modelBuilder.Entity(typeof(NonPrimitiveAsPropertyEntity), ConfigurationSource.Convention);
entityTypeBuilder.Property("Property", typeof(NavigationAsProperty), ConfigurationSource.Convention);
Assert.Equal(CoreStrings.PropertyNotMapped("Property", typeof(NonPrimitiveAsPropertyEntity).FullName),
Assert.Throws<InvalidOperationException>(() => new PropertyMappingValidationConvention().Apply(modelBuilder)).Message);
}
示例13: Throws_when_added_property_is_not_mapped_to_store_even_if_configured_to_use_column_type
public void Throws_when_added_property_is_not_mapped_to_store_even_if_configured_to_use_column_type()
{
var modelBuilder = new InternalModelBuilder(new Model(), new ConventionSet());
var entityTypeBuilder = modelBuilder.Entity(typeof(NonPrimitiveAsPropertyEntity), ConfigurationSource.Convention);
entityTypeBuilder.Property("Property", typeof(long), ConfigurationSource.Convention).Relational(ConfigurationSource.Convention).ColumnType("some_int_mapping");
Assert.Equal(CoreStrings.PropertyNotMapped("Property", typeof(NonPrimitiveAsPropertyEntity).FullName),
Assert.Throws<InvalidOperationException>(() => new RelationalPropertyMappingValidationConvention(new TestRelationalTypeMapper()).Apply(modelBuilder)).Message);
}
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:9,代码来源:RelationalPropertyMappingValidationConventionTest.cs
示例14: Throws_when_nonprimitive_value_type_property_is_not_added_or_ignored
public virtual void Throws_when_nonprimitive_value_type_property_is_not_added_or_ignored()
{
var modelBuilder = new InternalModelBuilder(new Model());
var entityTypeBuilder = modelBuilder.Entity(typeof(NonPrimitiveValueTypePropertyEntity), ConfigurationSource.Convention);
Assert.Equal(
CoreStrings.PropertyNotAdded(
typeof(NonPrimitiveValueTypePropertyEntity).DisplayName(fullName: false), "Property", typeof(CancellationToken).Name),
Assert.Throws<InvalidOperationException>(() => CreateConvention().Apply(modelBuilder)).Message);
}
示例15: NotMappedAttribute_overrides_configuration_from_convention_source
public void NotMappedAttribute_overrides_configuration_from_convention_source()
{
var modelBuilder = new InternalModelBuilder(new Model());
var entityBuilder = modelBuilder.Entity(typeof(A), ConfigurationSource.Convention);
new NotMappedEntityTypeAttributeConvention().Apply(entityBuilder);
Assert.Equal(0, modelBuilder.Metadata.GetEntityTypes().Count());
}