CityInfoMap.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.ComponentModel.DataAnnotations.Schema;
  2. using System.Data.Entity.ModelConfiguration;
  3. namespace YZXYH.Repository.Models.Mapping
  4. {
  5. public class CityInfoMap : EntityTypeConfiguration<CityInfo>
  6. {
  7. public CityInfoMap()
  8. {
  9. // Primary Key
  10. this.HasKey(t => t.Id);
  11. // Properties
  12. this.Property(t => t.Id)
  13. .IsRequired()
  14. .HasMaxLength(50);
  15. this.Property(t => t.CityName)
  16. .IsRequired()
  17. .HasMaxLength(50);
  18. this.Property(t => t.Province)
  19. .HasMaxLength(50);
  20. this.Property(t => t.SortNo)
  21. .IsFixedLength()
  22. .HasMaxLength(4);
  23. this.Property(t => t.IsLocked)
  24. .IsRequired()
  25. .IsFixedLength()
  26. .HasMaxLength(1);
  27. // Table & Column Mappings
  28. this.ToTable("CityInfos");
  29. this.Property(t => t.Id).HasColumnName("Id");
  30. this.Property(t => t.CityName).HasColumnName("CityName");
  31. this.Property(t => t.Province).HasColumnName("Province");
  32. this.Property(t => t.SortNo).HasColumnName("SortNo");
  33. this.Property(t => t.IsLocked).HasColumnName("IsLocked");
  34. this.Property(t => t.Remark).HasColumnName("Remark");
  35. }
  36. }
  37. }