本文整理汇总了C#中ModelBuilder.HasPostgresExtension方法的典型用法代码示例。如果您正苦于以下问题:C# ModelBuilder.HasPostgresExtension方法的具体用法?C# ModelBuilder.HasPostgresExtension怎么用?C# ModelBuilder.HasPostgresExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelBuilder
的用法示例。
在下文中一共展示了ModelBuilder.HasPostgresExtension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnModelCreating
protected override void OnModelCreating(ModelBuilder builder)
{
//UserRole关联配置
builder.Entity<UserRole>()
.HasKey(ur => new { ur.UserId, ur.RoleId });
//RoleMenu关联配置
builder.Entity<RoleMenu>()
.HasKey(rm => new { rm.RoleId, rm.MenuId });
builder.Entity<RoleMenu>()
.HasOne(rm => rm.Role)
.WithMany(r => r.RoleMenus)
.HasForeignKey(rm => rm.RoleId).HasForeignKey(rm => rm.MenuId);
//启用Guid主键类型扩展
builder.HasPostgresExtension("uuid-ossp");
base.OnModelCreating(builder);
}
示例2: OnModelCreating
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
ICoreTableNames tableNames = this.GetService<ICoreTableNames>();
if (tableNames == null)
{
tableNames = new CoreTableNames();
}
modelBuilder.HasPostgresExtension("uuid-ossp");
modelBuilder.Entity<SiteSettings>(entity =>
{
entity.ForNpgsqlToTable(tableNames.TablePrefix + tableNames.SiteTableName);
entity.HasKey(p => p.Id);
entity.Property(p => p.Id)
//.ForSqlServerHasColumnType("uniqueidentifier")
//.ForSqlServerHasDefaultValueSql("newid()")
;
entity.Property(p => p.AliasId)
.HasMaxLength(36)
;
//entity.Property(u => u.ConcurrencyStamp)
// .IsConcurrencyToken()
// .HasMaxLength(50)
// ;
entity.HasIndex(p => p.AliasId);
entity.Property(p => p.SiteName)
.HasMaxLength(255)
.IsRequired();
entity.Property(p => p.Theme)
.HasMaxLength(100);
entity.Property(p => p.AllowNewRegistration)
.IsRequired()
//.ForSqlServerHasColumnType("bit")
//.ForSqlServerHasDefaultValue(true)
;
entity.Property(p => p.RequireConfirmedEmail)
.IsRequired()
//.ForSqlServerHasColumnType("bit")
//.ForSqlServerHasDefaultValue(false)
;
entity.Property(p => p.RequireConfirmedPhone)
.IsRequired()
//.ForSqlServerHasColumnType("bit")
//.ForSqlServerHasDefaultValue(false)
;
entity.Property(p => p.IsServerAdminSite)
.IsRequired()
//.ForSqlServerHasColumnType("bit")
//.ForSqlServerHasDefaultValue(false)
;
entity.Property(p => p.UseLdapAuth)
.IsRequired()
//.ForSqlServerHasColumnType("bit")
//.ForSqlServerHasDefaultValue(false)
;
entity.Property(p => p.AutoCreateLdapUserOnFirstLogin)
.IsRequired()
//.ForSqlServerHasColumnType("bit")
// .ForSqlServerHasDefaultValue(true)
;
entity.Property(p => p.LdapServer)
.HasMaxLength(255);
;
entity.Property(p => p.LdapPort)
//.IsRequired()
//.ForSqlServerHasColumnType("int")
// .HasDefaultValue(389)
//.ValueGeneratedNever()
;
entity.Property(p => p.LdapDomain)
.HasMaxLength(255);
;
entity.Property(p => p.LdapRootDN)
.HasMaxLength(255);
;
entity.Property(p => p.LdapUserDNKey)
.HasMaxLength(10);
;
entity.Property(p => p.ReallyDeleteUsers)
.IsRequired()
//.........这里部分代码省略.........