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


C# ModelBuilder.HasDefaultSchema方法代码示例

本文整理汇总了C#中ModelBuilder.HasDefaultSchema方法的典型用法代码示例。如果您正苦于以下问题:C# ModelBuilder.HasDefaultSchema方法的具体用法?C# ModelBuilder.HasDefaultSchema怎么用?C# ModelBuilder.HasDefaultSchema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModelBuilder的用法示例。


在下文中一共展示了ModelBuilder.HasDefaultSchema方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnModelCreating

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.HasDefaultSchema("kraken");

            modelBuilder.Entity<ReleaseBatchItem>().HasOne(e => e.Batch).WithMany(e => e.Items).OnDelete(DeleteBehavior.Cascade);

            modelBuilder.Entity<ReleaseBatchItem>().HasAlternateKey(e => new { e.ReleaseBatchId, e.ProjectId });
        }
开发者ID:gitter-badger,项目名称:OctopusDeploy-Kraken,代码行数:10,代码来源:ApplicationDbContext.cs

示例2: BuildTargetModel

        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
            modelBuilder
                .HasDefaultSchema("mc")
                .HasAnnotation("ProductVersion", "1.0.0-rc2-20901")
                .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

            modelBuilder.Entity("MenusSample.Menu", b =>
                {
                    b.Property<int>("MenuId")
                        .ValueGeneratedOnAdd();

                    b.Property<int>("MenuCardId");

                    b.Property<decimal>("Price")
                        .HasColumnType("Money");

                    b.Property<string>("Text")
                        .HasAnnotation("MaxLength", 120);

                    b.HasKey("MenuId");

                    b.HasIndex("MenuCardId");

                    b.ToTable("Menus");
                });

            modelBuilder.Entity("MenusSample.MenuCard", b =>
                {
                    b.Property<int>("MenuCardId")
                        .ValueGeneratedOnAdd();

                    b.Property<string>("Title")
                        .HasAnnotation("MaxLength", 50);

                    b.HasKey("MenuCardId");

                    b.ToTable("MenuCards");
                });

            modelBuilder.Entity("MenusSample.Menu", b =>
                {
                    b.HasOne("MenusSample.MenuCard")
                        .WithMany()
                        .HasForeignKey("MenuCardId")
                        .OnDelete(DeleteBehavior.Cascade);
                });
        }
开发者ID:ProfessionalCSharp,项目名称:ProfessionalCSharp6,代码行数:48,代码来源:20160522083613_InitMenuCards.Designer.cs

示例3: OnModelCreating

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.HasDefaultSchema("kraken");

            modelBuilder.Entity<ApplicationUser>().HasKey(e => e.UserName);

            modelBuilder.Entity<ReleaseBatch>().HasKey(e => e.Id);
            modelBuilder.Entity<ReleaseBatch>().HasIndex(e => e.Name).IsUnique();

            modelBuilder.Entity<ReleaseBatch>().HasKey(e => e.Id);
            modelBuilder.Entity<ReleaseBatchItem>().HasOne(e => e.Batch).WithMany(e => e.Items).OnDelete(DeleteBehavior.Cascade);
            modelBuilder.Entity<ReleaseBatchItem>().HasAlternateKey(e => new { e.ReleaseBatchId, e.ProjectId });

            modelBuilder.Entity<ReleaseBatchLogo>().HasKey(e => e.ReleaseBatchId);
            modelBuilder.Entity<ReleaseBatchLogo>().HasOne(e => e.Batch).WithOne(e => e.Logo).OnDelete(DeleteBehavior.Cascade);
        }
开发者ID:Zywave,项目名称:OctopusDeploy-Kraken,代码行数:18,代码来源:ApplicationDbContext.cs

示例4: OnModelCreating

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.HasDefaultSchema("mc");

            modelBuilder.Entity<MenuCard>()
                .ToTable("MenuCards")
                .HasKey(c => c.MenuCardId);

            modelBuilder.Entity<MenuCard>()
                .Property<int>(c => c.MenuCardId)
                .ValueGeneratedOnAdd();

            modelBuilder.Entity<MenuCard>()
                .Property<string>(c => c.Title)
                .HasMaxLength(50);

            modelBuilder.Entity<Menu>()
                .ToTable("Menus")
                .HasKey(m => m.MenuId);

            modelBuilder.Entity<Menu>()
                .Property<int>(m => m.MenuId)
                .ValueGeneratedOnAdd();

            modelBuilder.Entity<Menu>()
                .Property<string>(m => m.Text)
                .HasMaxLength(120);

            modelBuilder.Entity<Menu>()
                .Property<decimal>(m => m.Price)
                .HasColumnType("Money");

            modelBuilder.Entity<MenuCard>()
                .HasMany(c => c.Menus)
                .WithOne(m => m.MenuCard);
            modelBuilder.Entity<Menu>()
                .HasOne(m => m.MenuCard)
                .WithMany(c => c.Menus)
                .HasForeignKey(m => m.MenuCardId);
        }
开发者ID:ProfessionalCSharp,项目名称:ProfessionalCSharp6,代码行数:42,代码来源:MenusContext.cs

示例5: CreateFromDatabaseModel

        protected virtual IModel CreateFromDatabaseModel([NotNull] DatabaseModel databaseModel)
        {
            Check.NotNull(databaseModel, nameof(databaseModel));

            var modelBuilder = new ModelBuilder(new ConventionSet());

            _tableNamer = new CSharpUniqueNamer<TableModel>(t => t.Name);
            _columnNamers = new Dictionary<TableModel, CSharpUniqueNamer<ColumnModel>>();

            VisitDatabaseModel(modelBuilder, databaseModel);

            if (!string.IsNullOrEmpty(databaseModel.DefaultSchemaName))
            {
                modelBuilder.HasDefaultSchema(databaseModel.DefaultSchemaName);
            }

            if (!string.IsNullOrEmpty(databaseModel.DatabaseName))
            {
                modelBuilder.Model.Relational().DatabaseName = databaseModel.DatabaseName;
            }

            return modelBuilder.Model;
        }
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:23,代码来源:RelationalScaffoldingModelFactory.cs

示例6: OnModelCreating

        protected override void OnModelCreating(ModelBuilder builder)
        {
            builder.HasDefaultSchema("mab");

            base.OnModelCreating(builder);
        }
开发者ID:mattschwartz,项目名称:mab,代码行数:6,代码来源:DataContext.cs

示例7: OnModelCreating

 protected override void OnModelCreating(ModelBuilder modelBuilder)
 {
     modelBuilder.HasDefaultSchema("blogging");
 }
开发者ID:Yinqingwen,项目名称:EntityFramework.Docs,代码行数:4,代码来源:DefaultSchema.cs

示例8: OnModelCreating

 protected override void OnModelCreating(ModelBuilder modelBuilder)
 {
     modelBuilder.HasDefaultSchema("public");
     modelBuilder.Entity<Position>()
         .HasKey(p => p.Id);
 }
开发者ID:tobiasterstad,项目名称:space,代码行数:6,代码来源:SpaceshipTrackerContext.cs


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