private static void ConfigureEntity(TypeConventionConfiguration configuration, EntityElement entityElement) { // add annotation configuration.Configure(x => x.HasTableAnnotation(AnnotationKey, entityElement.Identity.Id)); // update entity set name configuration.Configure(x => x.HasEntitySetName(entityElement.EntitySetName ?? entityElement.ResolveName())); // declare keys configuration.Configure(x => x.HasKey(entityElement.KeyProperties.Select(p => p.ResolveName()))); foreach (var propertyElement in entityElement.Properties) { var propertyType = propertyElement.PropertyType; if (propertyType.TypeKind == StructuralModelTypeKind.Enum) { continue; } var propertyName = propertyElement.ResolveName(); if (propertyElement.IsNullable) { configuration.Configure(x => x.Property(propertyName).IsOptional()); } else { configuration.Configure(x => x.Property(propertyName).IsRequired()); } } }
private static void ConfigureTable(TypeConventionConfiguration configuration, IMetadataElement tableElement) { string schemaName; var tableName = tableElement.ResolveName(); ParseTableName(ref tableName, out schemaName); configuration.Configure(x => x.ToTable(tableName, schemaName)); configuration.Configure(x => x.HasTableAnnotation(AnnotationKey, tableElement.Identity.Id)); }
public void Configure_evaluates_preconditions() { var conventions = new ConventionsConfiguration(); var entities = new TypeConventionConfiguration(conventions); var ex = Assert.Throws<ArgumentNullException>( () => entities.Configure(null)); Assert.Equal("entityConfigurationAction", ex.ParamName); }
public void Configure_evaluates_preconditions() { var conventions = new ConventionsConfiguration(); var entities = new TypeConventionConfiguration <object>(conventions); var ex = Assert.Throws <ArgumentNullException>( () => entities.Configure(null)); Assert.Equal("entityConfigurationAction", ex.ParamName); }