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


C# ModelBuilder类代码示例

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


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

示例1: OnModelCreating

 protected override void OnModelCreating(ModelBuilder modelBuilder)
 {
     foreach (var relationship in modelBuilder.Model.GetEntityTypes().SelectMany(e => e.GetForeignKeys()))
     {
         relationship.DeleteBehavior = DeleteBehavior.Restrict;
     }
 }
开发者ID:gitter-badger,项目名称:QueueDodge,代码行数:7,代码来源:QueueDodgeDB.cs

示例2: OnModelCreating

 protected override void OnModelCreating(ModelBuilder modelBuilder)
 {
     modelBuilder.Entity<KettleChips>()
         .Property(e => e.BestBuyDate)
         .StoreGeneratedPattern(StoreGeneratedPattern.Identity)
         .DefaultValue(new DateTime(2035, 9, 25));
 }
开发者ID:aishaloshik,项目名称:EntityFramework,代码行数:7,代码来源:DefaultValuesTest.cs

示例3: OnModelCreating

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

            modelBuilder.Entity<CustomerOrderHistory>().HasKey(coh => coh.ProductName);
            modelBuilder.Entity<MostExpensiveProduct>().HasKey(mep => mep.TenMostExpensiveProducts);
        }
开发者ID:ChuYuzhi,项目名称:EntityFramework,代码行数:7,代码来源:NorthwindSprocQueryRelationalFixture.cs

示例4: OnModelCreating

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<LpaUser>(e =>
            {
                e.Key(p => p.Id);

                e.Property(p => p.Id).UseSqlServerSequenceHiLo("LpaUserSeq", "dbo");
                e.Property(p => p.Username).MaxLength(120).Required();
                e.Property(p => p.Password).MaxLength(150).Required();
                e.Property(p => p.PasswordSalt).MaxLength(100).Required();
                e.Property(p => p.Created).Required().ValueGeneratedNever().HasSqlServerDefaultValueSql("sysdatetime()");

                e.Collection(p => p.Claims).InverseReference(p => p.User);
                e.ToSqlServerTable("Users");
            });

            modelBuilder.Entity<LpaUserClaim>(e =>
            {
                e.Key(p=>new { p.UserId, p.ClaimId }).SqlServerClustered();
                e.Reference(p => p.Claim).InverseCollection(p => p.Users).Required();
                e.Reference(p => p.User).InverseCollection(p => p.Claims).Required();
                e.ToSqlServerTable("UserClaims");
            });

            modelBuilder.Entity<LpaClaim>(e =>
            {
                e.Key(p => p.Id).SqlServerClustered();
                e.Property(p => p.Name).MaxLength(125).Required();
                e.Property(p => p.Value).MaxLength(150).Required();
                e.Collection(p => p.Users).InverseReference(p => p.Claim);
                e.ToSqlServerTable("Claims");
            });
        }
开发者ID:nteague22,项目名称:LPA-Site,代码行数:33,代码来源:AuthContext.cs

示例5: BuildModel

        public override void BuildModel(ModelBuilder builder)
        {
            builder
                .Annotation("ProductVersion", "7.0.0-beta6-13815");

            builder.Entity("EF7ProjectLemon.Auth", b =>
                {
                    b.Property<int>("AuthId")
                        .ValueGeneratedOnAdd();

                    b.Property<string>("Login");

                    b.Key("AuthId");
                });

            builder.Entity("EF7ProjectLemon.Person", b =>
                {
                    b.Property<int>("PersonId")
                        .ValueGeneratedOnAdd();

                    b.Property<string>("Name");

                    b.Key("PersonId");
                });
        }
开发者ID:AVVlasov,项目名称:EF7ProjectLemon,代码行数:25,代码来源:LemonContextModelSnapshot.cs

示例6: CreateModel

        protected Model CreateModel()
        {
            var modelBuilder = new ModelBuilder(new ConventionSet());

            modelBuilder.Entity<MappingQueryTestBase.MappedCustomer>(e =>
                {
                    e.Key(c => c.CustomerID);
                    e.Property(c => c.CompanyName2).Metadata.Relational().Column = "Broken";
                    e.Metadata.Relational().Table = "Broken";
                    if (!string.IsNullOrEmpty(DatabaseSchema))
                    {
                        e.Metadata.Relational().Schema = "wrong";
                    }
                });

            modelBuilder.Entity<MappingQueryTestBase.MappedEmployee>(e =>
                {
                    e.Key(em => em.EmployeeID);
                    e.Property(em => em.City2).Metadata.Relational().Column = "City";
                    e.Metadata.Relational().Table = "Employees";
                    e.Metadata.Relational().Schema = DatabaseSchema;
                });

            modelBuilder.Entity<MappingQueryTestBase.MappedOrder>(e =>
                {
                    e.Key(o => o.OrderID);
                    e.Property(em => em.ShipVia2).Metadata.Relational().Column = "ShipVia";
                    e.Metadata.Relational().Table = "Orders";
                    e.Metadata.Relational().Schema = DatabaseSchema;
                });

            OnModelCreating(modelBuilder);

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

示例7: BuildModel

        public override void BuildModel(ModelBuilder builder)
        {
            builder
                .Annotation("ProductVersion", "7.0.0-beta6-13815");

            builder.Entity("OoadProjekatBaza.RestoranBaza.Models.Restoran", b =>
                {
                    b.Property<int>("RestoranId")
                        .ValueGeneratedOnAdd();

                    b.Property<float>("GeoDuzina");

                    b.Property<float>("GeoSirina");

                    b.Property<string>("Naziv");

                    b.Property<string>("Opis");

                    b.Property<float>("Rating");

                    b.Property<byte[]>("Slika")
                        .Annotation("Relational:ColumnType", "image");

                    b.Property<string>("Telefon");

                    b.Property<string>("fourSqaureId");

                    b.Key("RestoranId");
                });
        }
开发者ID:ooad-2015-2016,项目名称:Obavijesti,代码行数:30,代码来源:RestoranDbContextModelSnapshot.cs

示例8: OnModelCreating

 protected override void OnModelCreating(ModelBuilder modelBuilder)
 {
     // Make Blog.Url required
     modelBuilder.Entity<Blog>()
         .Property(b => b.Url)
         .IsRequired();
 }
开发者ID:peterblazejewicz,项目名称:ef-generator-aspnet,代码行数:7,代码来源:Model.cs

示例9: BuildModel

        protected override void BuildModel(ModelBuilder modelBuilder)
        {
            modelBuilder
                .Annotation("ProductVersion", "7.0.0-beta8-15964")
                .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

            modelBuilder.Entity("PhoneSpotter.Models.PhoneSpotting", b =>
                {
                    b.Property<int>("PhoneSpottingId")
                        .ValueGeneratedOnAdd();

                    b.Property<double>("Latitude");

                    b.Property<double>("Longitude");

                    b.Property<string>("Notes");

                    b.Property<string>("PhoneManufacturer");

                    b.Property<string>("PhoneModel");

                    b.Property<DateTime>("SpotTime");

                    b.HasKey("PhoneSpottingId");
                });
        }
开发者ID:jeffa00,项目名称:WinPhoneSpotter2,代码行数:26,代码来源:PhoneSpottingDbContextModelSnapshot.cs

示例10: BuildTargetModel

        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
            modelBuilder
                .HasAnnotation("ProductVersion", "7.0.0-beta8-15964")
                .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

            modelBuilder.Entity("Dorothy.Models.Guest", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd();

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

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

                    b.Property<string>("Group");

                    b.Property<bool>("HasEmail");

                    b.Property<bool>("HasInvitation");

                    b.Property<bool>("IsOptional");

                    b.Property<string>("Names");

                    b.Property<string>("Notes");

                    b.HasKey("Id");
                });
        }
开发者ID:saxx,项目名称:Project-Dorothy,代码行数:30,代码来源:20151026181902_HasEmail.Designer.cs

示例11: OnModelCreating

 protected override void OnModelCreating(ModelBuilder modelBuilder)
 {
     modelBuilder.Entity<Parent>()
         .HasMany(b => b.Children)
         .WithOne(b => b.MyParent)
         .HasForeignKey(b => b.ParentId);
 }
开发者ID:adwardliu,项目名称:EntityFramework,代码行数:7,代码来源:SqliteForeignKeyTest.cs

示例12: BuildModel

        protected override void BuildModel(ModelBuilder modelBuilder)
        {
            modelBuilder
                .HasAnnotation("ProductVersion", "1.0.1");

            modelBuilder.Entity("cloudscribe.Core.IdentityServer.EFCore.Entities.PersistedGrant", b =>
                {
                    b.Property<string>("Key");

                    b.Property<string>("Type");

                    b.Property<string>("ClientId")
                        .IsRequired()
                        .HasAnnotation("MaxLength", 200);

                    b.Property<DateTime>("CreationTime");

                    b.Property<string>("Data")
                        .IsRequired();

                    b.Property<DateTime>("Expiration");

                    b.Property<string>("SiteId")
                        .IsRequired()
                        .HasAnnotation("MaxLength", 36);

                    b.Property<string>("SubjectId");

                    b.HasKey("Key", "Type");

                    b.HasIndex("SiteId");

                    b.ToTable("csids_PersistedGrants");
                });
        }
开发者ID:joeaudette,项目名称:cloudscribe,代码行数:35,代码来源:PersistedGrantDbContextModelSnapshot.cs

示例13: BuildModel

        protected override void BuildModel(ModelBuilder modelBuilder)
        {
            modelBuilder
                .HasAnnotation("ProductVersion", "1.0.0-rc2-20901");

            modelBuilder.Entity("LinkThere.Models.Link", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd();

                    b.Property<int>("ClickCount")
                        .IsConcurrencyToken();

                    b.Property<string>("Key")
                        .IsRequired();

                    b.Property<string>("LinkUrl")
                        .IsRequired();

                    b.HasKey("Id");

                    b.HasIndex("Key")
                        .IsUnique();

                    b.ToTable("Links");
                });
        }
开发者ID:ddreier,项目名称:LinkThere,代码行数:27,代码来源:LinkThereContextModelSnapshot.cs

示例14: RegisterModels

        public void RegisterModels(ModelBuilder modelbuilder)
        {
            modelbuilder.Entity<Dictionary>(etb =>
            {
              etb.HasKey(e => e.Id);
              etb.Property(e => e.Id).UseSqlServerIdentityColumn();
              etb.ForSqlServerToTable("Dictionaries");
            }
              );

              modelbuilder.Entity<Culture>(etb =>
            {
              etb.HasKey(e => e.Id);
              etb.Property(e => e.Id).UseSqlServerIdentityColumn();
              etb.ForSqlServerToTable("Cultures");
            }
              );

              modelbuilder.Entity<Localization>(etb =>
            {
              etb.HasKey(e => e.Id);
              etb.Property(e => e.Id).UseSqlServerIdentityColumn();
              etb.ForSqlServerToTable("Localizations");
            }
              );
        }
开发者ID:rajendra1809,项目名称:Platformus,代码行数:26,代码来源:ModelRegistrar.cs

示例15: BuildTargetModel

        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
            modelBuilder
                .HasAnnotation("ProductVersion", "1.1.0-rtm-22752")
                .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

            modelBuilder.Entity("Domain.Bag", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd();

                    b.Property<string>("Description");

                    b.Property<string>("Factory");

                    b.Property<string>("ImageLink");

                    b.Property<string>("Name");

                    b.Property<string>("Owner");

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

                    b.Property<DateTime?>("TimeBought");

                    b.Property<DateTime>("TimeCreation");

                    b.HasKey("Id");

                    b.ToTable("Bags");
                });
        }
开发者ID:kostya9,项目名称:OP,代码行数:32,代码来源:20161125165403_Bags.Designer.cs


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