Example #1
0
        /// <summary>
        /// Maps the specified entity type builder.
        /// </summary>
        /// <param name="entityTypeBuilder">The entity type builder.</param>
        public override void Map(EntityTypeBuilder <CountryEntity> entityTypeBuilder)
        {
            // Table
            entityTypeBuilder.ToTable("Country", SchemaName);

            // Primary Key
            entityTypeBuilder.HasKey(x => x.Id);

            // Properties
            entityTypeBuilder.Property(x => x.DisplayName).HasColumnType(ColumnTypes.GetNVarCharWithSpecifiedLength()).IsRequired();
            entityTypeBuilder.Property(x => x.TwoDigitsAlphabeticCode).IsRequired().HasMaxLength(2);
            entityTypeBuilder.Property(x => x.ThreeDigitsAlphabeticCode).IsRequired().HasMaxLength(3);
        }
Example #2
0
        /// <summary>
        /// Maps the specified entity type builder.
        /// </summary>
        /// <param name="entityTypeBuilder">The entity type builder.</param>
        public override void Map(EntityTypeBuilder <SettingEntity> entityTypeBuilder)
        {
            // Table
            entityTypeBuilder.ToTable("Setting", SchemaName);

            // Primary Key
            entityTypeBuilder.HasKey(x => x.Id);

            // Properties
            entityTypeBuilder.Property(x => x.UniqueName).HasColumnType(ColumnTypes.GetNVarCharWithSpecifiedLength(ColumnLengths.UniqueName)).IsRequired();
            entityTypeBuilder.Property(x => x.Value).HasColumnType(ColumnTypes.NVarCharMax).IsRequired();

            // Index
            entityTypeBuilder.HasIndex(x => x.UniqueName).IsUnique();
        }
        /// <summary>
        /// Maps the specified entity type builder.
        /// </summary>
        /// <param name="entityTypeBuilder">The entity type builder.</param>
        public override void Map(EntityTypeBuilder <CityEntity> entityTypeBuilder)
        {
            // Table
            entityTypeBuilder.ToTable("City", SchemaName);

            // Primary Key
            entityTypeBuilder.HasKey(x => x.Id);

            // Properties
            entityTypeBuilder.Property(x => x.CountyId);
            entityTypeBuilder.Property(x => x.DisplayName).HasColumnType(ColumnTypes.GetNVarCharWithSpecifiedLength()).IsRequired();

            // Relationships
            entityTypeBuilder.HasOne(x => x.County)
            .WithMany()
            .HasForeignKey(x => x.CountyId);
        }
 public void GetNVarCharWithSpecifiedLength_Value_Equals()
 {
     // Arrange & Act & Assert
     Assert.Equal("nvarchar(255)", ColumnTypes.GetNVarCharWithSpecifiedLength());
     Assert.Equal("nvarchar(100)", ColumnTypes.GetNVarCharWithSpecifiedLength(100));
 }