diff --git a/Teknik/Data/TeknikEntities.cs b/Teknik/Data/TeknikEntities.cs index bebfaf5..352b945 100644 --- a/Teknik/Data/TeknikEntities.cs +++ b/Teknik/Data/TeknikEntities.cs @@ -176,6 +176,9 @@ namespace Teknik.Data modelBuilder.Entity().HasOne(t => t.User).WithMany(u => u.Transfers); modelBuilder.Entity().HasOne(t => t.Paste).WithMany(p => p.Transfers); + // Transactions + modelBuilder.Entity().Property(t => t.Amount).HasColumnType("decimal(19, 5)"); + // Users modelBuilder.Entity().ToTable("Users"); modelBuilder.Entity().ToTable("UserRoles"); @@ -218,20 +221,17 @@ namespace Teknik.Data modelBuilder.Entity().ToTable("TransferTypes"); // Custom Attributes - //foreach (var entityType in modelBuilder.Model.GetEntityTypes()) - //{ - // foreach (var property in entityType.GetProperties()) - // { - // var columnName = property.SqlServer().ColumnName; - // if (columnName.Length > 30) - // { - // throw new InvalidOperationException("Column name is greater than 30 characters - " + columnName); - // } - // } - //} - //modelBuilder.Conventions.Add(new AttributeToColumnAnnotationConvention( - // "CaseSensitive", - // (property, attributes) => attributes.Single().IsEnabled)); + foreach (var entityType in modelBuilder.Model.GetEntityTypes()) + { + foreach (var property in entityType.GetProperties()) + { + var attributes = property?.PropertyInfo?.GetCustomAttributes(typeof(CaseSensitiveAttribute), false); + if (attributes != null && attributes.Any()) + { + property.SetAnnotation("CaseSensitive", true); + } + } + } base.OnModelCreating(modelBuilder); }