当前位置: 首页>>代码示例>>C#>>正文


C# InternalModelBuilder.Entity方法代码示例

本文整理汇总了C#中InternalModelBuilder.Entity方法的典型用法代码示例。如果您正苦于以下问题:C# InternalModelBuilder.Entity方法的具体用法?C# InternalModelBuilder.Entity怎么用?C# InternalModelBuilder.Entity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在InternalModelBuilder的用法示例。


在下文中一共展示了InternalModelBuilder.Entity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Does_not_throw_when_navigation_is_added

        public void Does_not_throw_when_navigation_is_added()
        {
            var modelBuilder = new InternalModelBuilder(new Model(), new ConventionSet());
            var entityTypeBuilder = modelBuilder.Entity(typeof(NavigationEntity), ConfigurationSource.Convention);
            var referencedEntityTypeBuilder = modelBuilder.Entity(typeof(PrimitivePropertyEntity), ConfigurationSource.Convention);
            referencedEntityTypeBuilder.Ignore("Property", ConfigurationSource.Convention);
            entityTypeBuilder.Relationship(referencedEntityTypeBuilder, "Navigation", null, ConfigurationSource.Convention);

            new PropertyMappingValidationConvention().Apply(modelBuilder);
        }
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:10,代码来源:PropertyMappingValidationConventionTest.cs

示例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);
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:7,代码来源:InternalIndexBuilderTest.cs

示例3: 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

示例4: 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);
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:8,代码来源:PropertyMappingValidationConventionTest.cs

示例5: 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);
        }
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:8,代码来源:PropertyMappingValidationConventionTest.cs

示例6: 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);
        }
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:8,代码来源:PropertyMappingValidationConventionTest.cs

示例7: 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);
        }
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:8,代码来源:PropertyMappingValidationConventionTest.cs

示例8: 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

示例9: 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);
        }
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:9,代码来源:PropertyMappingValidationConventionTest.cs

示例10: 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);
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:9,代码来源:PropertyMappingValidationConventionTest.cs

示例11: 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

示例12: 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());
            var entityTypeBuilder = modelBuilder.Entity(typeof(NonPrimitiveAsPropertyEntity), ConfigurationSource.Convention);
            entityTypeBuilder.Property("LongProperty", typeof(long), ConfigurationSource.Convention).Relational(ConfigurationSource.Convention).HasColumnType("some_int_mapping");

            Assert.Equal(CoreStrings.PropertyNotMapped(
                typeof(NonPrimitiveAsPropertyEntity).DisplayName(fullName: false), "LongProperty", typeof(long).DisplayName(fullName: false)),
                Assert.Throws<InvalidOperationException>(() => CreateConvention().Apply(modelBuilder)).Message);
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:10,代码来源:RelationalPropertyMappingValidationConventionTest.cs

示例13: 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);
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:10,代码来源:PropertyMappingValidationConventionTest.cs

示例14: 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());
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:10,代码来源:EntityTypeAttributeConventionTest.cs

示例15: NotMappedAttribute_does_not_override_configuration_from_explicit_source

        public void NotMappedAttribute_does_not_override_configuration_from_explicit_source()
        {
            var modelBuilder = new InternalModelBuilder(new Model(), new ConventionSet());

            var entityBuilder = modelBuilder.Entity(typeof(A), ConfigurationSource.Explicit);

            new NotMappedEntityTypeAttributeConvention().Apply(entityBuilder);

            Assert.Equal(1, modelBuilder.Metadata.EntityTypes.Count);
        }
开发者ID:491134648,项目名称:EntityFramework,代码行数:10,代码来源:EntityTypeAttributeConventionTest.cs


注:本文中的InternalModelBuilder.Entity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。