本文整理汇总了C#中ModelBuilder.HasSequence方法的典型用法代码示例。如果您正苦于以下问题:C# ModelBuilder.HasSequence方法的具体用法?C# ModelBuilder.HasSequence怎么用?C# ModelBuilder.HasSequence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelBuilder
的用法示例。
在下文中一共展示了ModelBuilder.HasSequence方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnModelCreating
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasSequence<int>("OrderNumbers", schema: "shared")
.StartsAt(1000)
.IncrementsBy(5);
modelBuilder.Entity<Order>()
.Property(o => o.OrderNo)
.HasDefaultValueSql("NEXT VALUE FOR shared.OrderNumbers");
}
示例2: OnModelCreating
//.........这里部分代码省略.........
entity.Property(e => e.Culture).HasColumnType("nchar(6)");
entity.Property(e => e.ModifiedDate)
.HasColumnType("datetime")
.HasDefaultValueSql("getdate()");
entity.Property(e => e.rowguid).HasDefaultValueSql("newid()");
});
modelBuilder.Entity<SalesOrderDetail>(entity =>
{
entity.HasKey(e => new { e.SalesOrderID, e.SalesOrderDetailID })
.HasName("PK_SalesOrderDetail_SalesOrderID_SalesOrderDetailID");
entity.HasIndex(e => e.ProductID)
.HasName("IX_SalesOrderDetail_ProductID");
entity.HasIndex(e => e.rowguid)
.HasName("AK_SalesOrderDetail_rowguid")
.IsUnique();
entity.Property(e => e.SalesOrderDetailID).ValueGeneratedOnAdd();
entity.Property(e => e.LineTotal)
.HasColumnType("numeric")
.ValueGeneratedOnAddOrUpdate();
entity.Property(e => e.ModifiedDate)
.HasColumnType("datetime")
.HasDefaultValueSql("getdate()");
entity.Property(e => e.UnitPrice).HasColumnType("money");
entity.Property(e => e.UnitPriceDiscount)
.HasColumnType("money")
.HasDefaultValueSql("0.0");
entity.Property(e => e.rowguid).HasDefaultValueSql("newid()");
});
modelBuilder.Entity<SalesOrder>(entity =>
{
entity.HasKey(e => e.SalesOrderID)
.HasName("PK_SalesOrderHeader_SalesOrderID");
entity.HasIndex(e => e.CustomerID)
.HasName("IX_SalesOrderHeader_CustomerID");
entity.HasIndex(e => e.SalesOrderNumber)
.HasName("AK_SalesOrderHeader_SalesOrderNumber")
.IsUnique();
entity.HasIndex(e => e.rowguid)
.HasName("AK_SalesOrderHeader_rowguid")
.IsUnique();
entity.Property(e => e.SalesOrderID).ForSqlServerUseSequenceHiLo("SalesOrderNumber", "SalesLT");
entity.Property(e => e.CreditCardApprovalCode).HasColumnType("varchar(15)");
entity.Property(e => e.DueDate).HasColumnType("datetime");
entity.Property(e => e.Freight)
.HasColumnType("money")
.HasDefaultValueSql("0.00");
entity.Property(e => e.ModifiedDate)
.HasColumnType("datetime")
.HasDefaultValueSql("getdate()");
entity.Property(e => e.OrderDate)
.HasColumnType("datetime")
.HasDefaultValueSql("getdate()");
entity.Property(e => e.RevisionNumber).HasDefaultValueSql("0");
entity.Property(e => e.SalesOrderNumber).ValueGeneratedOnAddOrUpdate();
entity.Property(e => e.ShipDate).HasColumnType("datetime");
entity.Property(e => e.Status).HasDefaultValueSql("1");
entity.Property(e => e.SubTotal)
.HasColumnType("money")
.HasDefaultValueSql("0.00");
entity.Property(e => e.TaxAmt)
.HasColumnType("money")
.HasDefaultValueSql("0.00");
entity.Property(e => e.TotalDue)
.HasColumnType("money")
.ValueGeneratedOnAddOrUpdate();
entity.Property(e => e.rowguid).HasDefaultValueSql("newid()");
});
modelBuilder.HasSequence<int>("SalesOrderNumber", "SalesLT");
}
示例3: OnModelCreating
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasSequence<int>("OrderNumbers");
}
示例4: OnModelCreating
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasSequence<int>("OrderNumbers", schema: "shared")
.StartsAt(1000)
.IncrementsBy(5);
}