This commit is contained in:
@@ -52,7 +52,6 @@ namespace AyaNova.Models
|
||||
}
|
||||
else
|
||||
property.Relational().ColumnName = property.Name.ToLowerInvariant();
|
||||
|
||||
}
|
||||
|
||||
foreach (var key in entity.GetKeys())
|
||||
@@ -69,21 +68,21 @@ namespace AyaNova.Models
|
||||
{
|
||||
index.Relational().Name = index.Relational().Name.ToLowerInvariant();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Indexes must be specified through fluent api unfortunately
|
||||
modelBuilder.Entity<FileAttachment>().HasIndex(p => p.StoredFileName);
|
||||
|
||||
|
||||
//Relationships
|
||||
modelBuilder.Entity<Locale>()
|
||||
.HasMany(c => c.LocaleItems)
|
||||
.WithOne(e => e.Locale)
|
||||
.IsRequired();//default delete behaviour is cascade when set to isrequired
|
||||
|
||||
|
||||
modelBuilder.Entity<User>()
|
||||
.HasOne(p => p.UserOptions)
|
||||
.WithOne(i => i.User)
|
||||
.HasForeignKey<UserOptions>(b => b.UserId);
|
||||
|
||||
|
||||
//-----------
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace AyaNova.Models
|
||||
[Required]
|
||||
public string Login { get; set; }
|
||||
[Required]
|
||||
public string Password { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Salt { get; set; }
|
||||
[Required]
|
||||
public AuthorizationRoles Roles { get; set; }
|
||||
public AuthorizationRoles Roles { get; set; }
|
||||
[Required]
|
||||
public long LocaleId { get; set; }
|
||||
public string DlKey { get; set; }
|
||||
@@ -31,11 +31,16 @@ namespace AyaNova.Models
|
||||
public UserType UserType { get; set; }
|
||||
[MaxLength(255)]
|
||||
public string EmployeeNumber { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public long? ClientId { get; set; }
|
||||
public long? HeadOfficeId { get; set; }
|
||||
public long? SubVendorId { get; set; }
|
||||
|
||||
|
||||
//relations
|
||||
//https://docs.microsoft.com/en-us/ef/core/modeling/relationships#other-relationship-patterns
|
||||
public UserOptions UserOptions { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
@@ -11,19 +11,25 @@ namespace AyaNova.Models
|
||||
public uint ConcurrencyToken { get; set; }
|
||||
[Required]
|
||||
public long OwnerId { get; set; }
|
||||
[Required]
|
||||
public long UserId { get; set; }
|
||||
|
||||
//-------------
|
||||
public string EmailAddress { get; set; }
|
||||
public decimal TimeZoneOffset { get; set; }
|
||||
public int UiColor { get; set; }
|
||||
|
||||
public UserOptions(long userId, long ownerId)
|
||||
//relations
|
||||
//https://docs.microsoft.com/en-us/ef/core/modeling/relationships#other-relationship-patterns
|
||||
public User User { get; set; }
|
||||
[Required]
|
||||
public long UserId { get; set; }//will be auto-set by EF due to relationship defined
|
||||
|
||||
|
||||
public UserOptions(long ownerId)
|
||||
{
|
||||
UserId=userId;
|
||||
TimeZoneOffset=0;
|
||||
UiColor=0;
|
||||
OwnerId=ownerId;
|
||||
|
||||
TimeZoneOffset = 0;
|
||||
UiColor = 0;
|
||||
OwnerId = ownerId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user