当前位置: 首页>>代码示例>>C#>>正文


C# ModelBuilder.HasSequence方法代码示例

本文整理汇总了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");
        }
开发者ID:Yinqingwen,项目名称:EntityFramework.Docs,代码行数:10,代码来源:SequenceUsed.cs

示例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");
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:101,代码来源:AdventureWorksContext.cs

示例3: OnModelCreating

 protected override void OnModelCreating(ModelBuilder modelBuilder)
 {
     modelBuilder.HasSequence<int>("OrderNumbers");
 }
开发者ID:Yinqingwen,项目名称:EntityFramework.Docs,代码行数:4,代码来源:Sequence.cs

示例4: OnModelCreating

 protected override void OnModelCreating(ModelBuilder modelBuilder)
 {
     modelBuilder.HasSequence<int>("OrderNumbers", schema: "shared")
         .StartsAt(1000)
         .IncrementsBy(5);
 }
开发者ID:CrazyHorse007,项目名称:EntityFramework.Docs,代码行数:6,代码来源:SequenceConfigured.cs


注:本文中的ModelBuilder.HasSequence方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。