Ejemplo n.º 1
0
 protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
 {
     modelBuilder.Entity <DemoEntity>().ToTable("Demo")
     .HasKey(e => e.Id)
     .Property(e => e.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
     base.OnModelCreating(modelBuilder);
 }
Ejemplo n.º 2
0
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove <System.Data.Entity.ModelConfiguration.Conventions.PluralizingTableNameConvention>();
            base.OnModelCreating(modelBuilder);
            modelBuilder.Entity <Site>().ToTable("Site");
            modelBuilder.Entity <WifiUser>().ToTable("WifiUser");
            modelBuilder.Entity <WifiUserLoginCredential>().ToTable("WifiUserLoginCredential");
            modelBuilder.Entity <UsersAddress>().ToTable("UsersAddress");
            modelBuilder.Entity <RtlsConfiguration>().ToTable("RtlsConfiguration");
            modelBuilder.Entity <RtlsArea>().ToTable("RtlsArea").HasKey(m => m.Id);
            modelBuilder.Entity <SiteFloor>().ToTable("SiteFloor");
            modelBuilder.Entity <Device>().ToTable("Device");
            modelBuilder.Entity <DeviceAssociateSite>().ToTable("DeviceAssociateSite");
            modelBuilder.Entity <LocationData>().ToTable("LocationData");
            modelBuilder.Entity <AppLog>().ToTable("AppLog");
            modelBuilder.Entity <TrackMacNotification>().ToTable("TrackMacNotification");
            modelBuilder.Entity <TrackMember>().ToTable("TrackMember");
            modelBuilder.Entity <OmniDeviceMapping>().ToTable("OmniDeviceMapping");
            modelBuilder.Entity <RtlsNotificationData>().ToTable("RtlsNotificationData");
            modelBuilder.Entity <NetWorkOfSite>().ToTable("NetWorkOfSite");

            modelBuilder.Entity <Site>()
            .HasOptional(f => f.RtlsConfiguration)
            .WithRequired(s => s.Site);

            modelBuilder.Entity <Device>().HasOptional(g => g.OmniDeviceMapping).WithRequired(h => h.Device);
        }
Ejemplo n.º 3
0
 protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
 {
     base.OnModelCreating(modelBuilder);
     modelBuilder.Configurations.Add(new A.Core.PermissionModule.Services.Mapping.RoleMap());
     modelBuilder.Configurations.Add(new A.Core.PermissionModule.Services.Mapping.PermissionMap());
     modelBuilder.Configurations.Add(new A.Core.PermissionModule.Services.Mapping.RolePermissionMap());
 }
Ejemplo n.º 4
0
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity <ApplicationUser>().Property(x => x.Balance).HasPrecision(18, 8);
            modelBuilder.Properties <decimal>().Configure(x => x.HasPrecision(18, 8));

            base.OnModelCreating(modelBuilder);
        }
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Entity <IdentityRole>().ToTable(BCM.Common.Constants.TablePrefix + "Roles");
            modelBuilder.Entity <IdentityUserClaim>().ToTable(BCM.Common.Constants.TablePrefix + "UserClaims");
            modelBuilder.Entity <IdentityUserLogin>().ToTable(BCM.Common.Constants.TablePrefix + "UserLogins");
            modelBuilder.Entity <IdentityUserRole>().ToTable(BCM.Common.Constants.TablePrefix + "UserRoles");
            modelBuilder.Entity <IdentityUser>().ToTable(BCM.Common.Constants.TablePrefix + "Users");
            modelBuilder.Entity <ApplicationUser>().ToTable(BCM.Common.Constants.TablePrefix + "Users");

            modelBuilder.Entity <Book>()
            .HasMany(a => a.Authors)
            .WithMany(a => a.Books)
            .Map(m =>
            {
                m.ToTable(BCM.Common.Constants.TablePrefix + "BookAuthor");
                m.MapLeftKey("BookId");
                m.MapRightKey("AuthorId");
            });

            modelBuilder.Entity <Book>()
            .HasMany(c => c.Categories)
            .WithMany(c => c.Books)
            .Map(m =>
            {
                m.ToTable(BCM.Common.Constants.TablePrefix + "BookCategory");
                m.MapLeftKey("BookId");
                m.MapRightKey("CategoryId");
            });
        }
        /// <summary>
        /// متد آن مدل کریتینگ برای اعمال کانفیگوریشن در کلاس ها
        /// </summary>
        /// <param name="modelBuilder"></param>
        protected override void OnModelCreating
            (System.Data.Entity.DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Configurations.Add(new Country.Configuration());
        }
Ejemplo n.º 7
0
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            /*modelBuilder.Entity<ResoultSaveModel>().HasKey(i => i.Id);
             * modelBuilder.Entity<ResoultSaveModel>().Property(i => i.Mark);
             * modelBuilder.Entity<ResoultSaveModel>().Property(i => i.UserName);
             * modelBuilder.Entity<ResoultSaveModel>().Property(i => i.Started);
             * modelBuilder.Entity<ResoultSaveModel>().Property(i => i.Finished);*/


            modelBuilder.Entity <TestModel>().HasKey(i => i.Id);
            modelBuilder.Entity <TestModel>().Property(i => i.title);
            modelBuilder.Entity <TestModel>().Property(i => i.Description);

            modelBuilder.Entity <TestModel>().HasMany(i => i.Questions)
            .WithRequired()
            .HasForeignKey(si => si.TestId);

            modelBuilder.Entity <Question>().HasKey(i => i.QuestionId);
            modelBuilder.Entity <Question>().Property(i => i.Text);

            modelBuilder.Entity <Question>().HasMany(i => i.Answers)
            .WithRequired()
            .HasForeignKey(si => si.QuestionId);

            modelBuilder.Entity <AnswerVariant>().HasKey(i => i.AnswerId);
            modelBuilder.Entity <AnswerVariant>().Property(i => i.Text);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Define the relations between tables
 /// </summary>
 /// <param name="modelBuilder"></param>
 protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
 {
     modelBuilder.Entity <Patient>().HasMany(x => x.DentalProcedures);
     modelBuilder.Entity <Patient>().HasMany(x => x.Diseases);
     modelBuilder.Entity <ProceduresTable>().HasMany(x => x.Cells);
     base.OnModelCreating(modelBuilder);
 }
Ejemplo n.º 9
0
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Configurations.Add(new AdminReMapping());
            modelBuilder.Configurations.Add(new ApplicationLogMapping());
            modelBuilder.Configurations.Add(new CustomerMapping());
            modelBuilder.Configurations.Add(new EmployeeMapping());
            modelBuilder.Configurations.Add(new IngredientMapping());
            modelBuilder.Configurations.Add(new OrderNoteMapping());
            modelBuilder.Configurations.Add(new OrderNoteDetailMapping());
            modelBuilder.Configurations.Add(new ProductMapping());
            modelBuilder.Configurations.Add(new ProductDetailMapping());
            modelBuilder.Configurations.Add(new ReceiptNoteMapping());
            modelBuilder.Configurations.Add(new ReceiptNoteDetailMapping());
            modelBuilder.Configurations.Add(new SalaryNoteMapping());
            modelBuilder.Configurations.Add(new WareHouseMapping());
            modelBuilder.Configurations.Add(new WorkingHistoryMapping());

            modelBuilder.Configurations.Add(new APWareHouseMapping());
            modelBuilder.Configurations.Add(new StockMapping());
            modelBuilder.Configurations.Add(new StockInMapping());
            modelBuilder.Configurations.Add(new StockInDetailsMapping());
            modelBuilder.Configurations.Add(new StockOutMapping());
            modelBuilder.Configurations.Add(new StockOutDetailsMapping());

            OnModelCreatingPartial(modelBuilder);
        }
Ejemplo n.º 10
0
        public static System.Data.Entity.DbModelBuilder CreateModel(System.Data.Entity.DbModelBuilder modelBuilder, string schema)
        {
            modelBuilder.Configurations.Add(new AdminReMapping(schema));
            modelBuilder.Configurations.Add(new ApplicationLogMapping(schema));
            modelBuilder.Configurations.Add(new CustomerMapping(schema));
            modelBuilder.Configurations.Add(new EmployeeMapping(schema));
            modelBuilder.Configurations.Add(new IngredientMapping(schema));
            modelBuilder.Configurations.Add(new OrderNoteMapping(schema));
            modelBuilder.Configurations.Add(new OrderNoteDetailMapping(schema));
            modelBuilder.Configurations.Add(new ProductMapping(schema));
            modelBuilder.Configurations.Add(new ProductDetailMapping(schema));
            modelBuilder.Configurations.Add(new ReceiptNoteMapping(schema));
            modelBuilder.Configurations.Add(new ReceiptNoteDetailMapping(schema));
            modelBuilder.Configurations.Add(new SalaryNoteMapping(schema));
            modelBuilder.Configurations.Add(new WareHouseMapping(schema));
            modelBuilder.Configurations.Add(new WorkingHistoryMapping(schema));

            modelBuilder.Configurations.Add(new APWareHouseMapping(schema));
            modelBuilder.Configurations.Add(new StockMapping(schema));
            modelBuilder.Configurations.Add(new StockInMapping(schema));
            modelBuilder.Configurations.Add(new StockInDetailsMapping(schema));
            modelBuilder.Configurations.Add(new StockOutMapping(schema));
            modelBuilder.Configurations.Add(new StockOutDetailsMapping(schema));

            return(modelBuilder);
        }
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove <PluralizingTableNameConvention>();
            //modelBuilder.Conventions.Remove<ManyToManyCascadeDeleteConvention>();

            base.OnModelCreating(modelBuilder);
        }
Ejemplo n.º 12
0
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            //base.OnModelCreating(modelBuilder);

            if (modelBuilder == null)
            {
                throw new ArgumentNullException("modelBuilder");
            }

            // Keep this:
            modelBuilder.Entity <IdentityUser>().ToTable("AspNetUsers");
            modelBuilder.Entity <IdentityUser>().HasMany <IdentityUserRole>((IdentityUser u) => u.Roles);
            modelBuilder.Entity <IdentityUserRole>().HasKey((IdentityUserRole r) =>
                                                            new { UserId = r.UserId, RoleId = r.RoleId }).ToTable("AspNetUserRoles");

            // Leave this alone:
            EntityTypeConfiguration <IdentityUserLogin> entityTypeConfiguration =
                modelBuilder.Entity <IdentityUserLogin>().HasKey((IdentityUserLogin l) =>
                                                                 new
            {
                UserId        = l.UserId,
                LoginProvider = l.LoginProvider,
                ProviderKey
                    = l.ProviderKey
            }).ToTable("AspNetUserLogins");

            EntityTypeConfiguration <IdentityUserClaim> table1 =
                modelBuilder.Entity <IdentityUserClaim>().ToTable("AspNetUserClaims");

            // Add this, so that IdentityRole can share a table with ApplicationRole:
            modelBuilder.Entity <IdentityRole>().ToTable("AspNetRoles");

            modelBuilder.Configurations.Add(new BarConfiguration());
            modelBuilder.Configurations.Add(new FundConfiguration());
        }
        //
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity <HomeVisit>().Property(x => x.GeoLat).HasPrecision(12, 8);
            modelBuilder.Entity <HomeVisit>().Property(x => x.GeoLng).HasPrecision(12, 8);

            base.OnModelCreating(modelBuilder);
        }
Ejemplo n.º 14
0
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity <Utilizator>().ToTable("Utilizatori");
            modelBuilder.Conventions.Remove <PluralizingTableNameConvention>();

            base.OnModelCreating(modelBuilder);
        }
Ejemplo n.º 15
0
        protected override void OnModelCreating(Entity.DbModelBuilder modelBuilder)
        {
            // Register all mappings from current assembly
            modelBuilder.Configurations.AddFromAssembly(GetType().Assembly);

            base.OnModelCreating(modelBuilder);
        }
Ejemplo n.º 16
0
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            //configure primary keys first
            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.Attendence>().HasKey(p => p.AttendenceId);
            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.Attendence>()
            .HasRequired(p => p.Student).WithMany(p => p.Attendences).HasForeignKey(p => p.StudentId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.Attendence>()
            .HasRequired(p => p.Course).WithMany(p => p.Attendences).HasForeignKey(p => p.CourseId);


            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.Attendence>()
            .HasRequired(p => p.TimeTable).WithMany().HasForeignKey(p => p.TimeTableId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.Course>().HasKey(p => p.CourseId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.CourseScedule>().HasKey(p => p.CourseSceduleId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.CourseScedule>().HasRequired(p => p.TimeTable).WithMany().HasForeignKey(p => p.TimeTableId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.Department>().HasKey(p => p.DepartmentId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.Department>().HasRequired(p => p.FileStorage).WithMany().HasForeignKey(p => p.FileStorageId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.DepartmentCourse>().HasKey(p => p.DepartmentCourseId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.DepartmentCourse>().HasRequired(p => p.Department).WithMany().HasForeignKey(p => p.DepartmentId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.DepartmentCourse>().HasRequired(p => p.Course).WithMany().HasForeignKey(p => p.CourseId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.Employee>().HasKey(p => p.EmployeeId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.Event>().HasKey(p => p.EventId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.Event>().HasRequired(p => p.EventTime).WithMany().HasForeignKey(p => p.EventTimeTableId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.FileStorage>().HasKey(p => p.FileStorageId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.Grade>().HasKey(p => p.GradeId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.News>().HasKey(p => p.NewsId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.Result>().HasKey(p => p.ResultId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.Result>().HasRequired(p => p.Student).WithMany().HasForeignKey(p => p.StudentId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.Result>().HasRequired(p => p.Course).WithMany().HasForeignKey(p => p.CourseId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.Result>().HasRequired(p => p.TimeTable).WithMany().HasForeignKey(p => p.TimeTableId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.Student>().HasKey(p => p.StudentId);

            modelBuilder.Entity <University.Service.Areas.HelpPage.Models.User>().HasOptional(p => p.UserRole).WithMany(p => p.Users).HasForeignKey(p => p.UserRoleId);

            modelBuilder.Entity <IdentityUserLogin>().HasKey <string>(l => l.UserId);

            modelBuilder.Entity <IdentityRole>().HasKey <string>(r => r.Id);

            modelBuilder.Entity <IdentityUserRole>().HasKey(r => new { r.RoleId, r.UserId });
        }
Ejemplo n.º 17
0
        /// <inheritdoc />
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            OnModelCreatingImpl(modelBuilder);

            modelBuilder.HasDefaultSchema("dbo");

            modelBuilder.Entity <global::Sandbox_EF6.Role>()
            .ToTable("Roles")
            .HasKey(t => t.Id);
            modelBuilder.Entity <global::Sandbox_EF6.Role>()
            .Property(t => t.Id)
            .IsRequired()
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            modelBuilder.Entity <global::Sandbox_EF6.User>()
            .ToTable("Users")
            .HasKey(t => t.Id);
            modelBuilder.Entity <global::Sandbox_EF6.User>()
            .Property(t => t.Id)
            .IsRequired()
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            modelBuilder.Entity <global::Sandbox_EF6.User>()
            .HasRequired(x => x.Role)
            .WithMany(x => x.Users)
            .Map(x => x.MapKey("Role_Id"));

            OnModelCreatedImpl(modelBuilder);
        }
Ejemplo n.º 18
0
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Entity <TestLangTable>().ToTable("TestLangTable");
            modelBuilder.Entity <TestLangTable2>().ToTable("TestLangTable2");
        }
Ejemplo n.º 19
0
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Entity <Dad>()
            .Property(x => x.DayOfBirth).IsRequired();
        }
        /// <inheritdoc />
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            OnModelCreatingImpl(modelBuilder);

            modelBuilder.HasDefaultSchema("dbo");

            modelBuilder.Entity <global::MultiContext.Context1.Entity1>()
            .ToTable("Entity1")
            .HasKey(t => t.Id);
            modelBuilder.Entity <global::MultiContext.Context1.Entity1>()
            .Property(t => t.Id)
            .IsRequired()
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            modelBuilder.Entity <global::MultiContext.Context1.Entity2>()
            .ToTable("Entity2")
            .HasKey(t => t.Id);
            modelBuilder.Entity <global::MultiContext.Context1.Entity2>()
            .Property(t => t.Id)
            .IsRequired()
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            modelBuilder.Entity <global::MultiContext.Context1.Entity2>()
            .HasRequired(x => x.Entity1)
            .WithMany(x => x.Entity2)
            .Map(x => x.MapKey("Entity1_Id"));

            OnModelCreatedImpl(modelBuilder);
        }
Ejemplo n.º 21
0
        //public DbSet<Contact> InquirySheet { get; set; }

        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            //里继承了DbContext,这个基类和下面的DbSet<>都是用于Code First模式的,当然DataBase First也可以用。同时我们要重写OnModelCreating()方法,在这个方法里移除表名复数的契约。比如我们在这里Model叫Movie,如果不加modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();这句话,在数据库表中表名会被设置为Movies。这种情况下,就需要移除这个契约。
            modelBuilder.Conventions.Remove <PluralizingTableNameConvention>();
            // 禁用一对多级联删除
            // modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
            // 禁用多对多级联删除
            //modelBuilder.Conventions.Remove<ManyToManyCascadeDeleteConvention>();
            // modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
            //modelBuilder.HasDefaultSchema("public");
            //modelBuilder.Configurations.Add(new ProductNMMap());
            //modelBuilder.Configurations.Add(new ContactConfiguration());

            #region 权限
            modelBuilder.Configurations.Add(new PermissionRoleConfigurationMap());
            modelBuilder.Configurations.Add(new PermissionModuleConfigurationMap());
            modelBuilder.Configurations.Add(new PermissionReRoleModuleConfigurationMap());
            modelBuilder.Configurations.Add(new UserMap());
            modelBuilder.Configurations.Add(new UserReRoleMap());
            #endregion
            //modelBuilder.Configurations.Add(new ResortMap());
            //modelBuilder.Entity<Contact>().MapToStoredProcedures();
            //modelBuilder.Configurations.Add(new CategoryMap());
            //modelBuilder.Configurations.Add(new ProductMap());
            //modelBuilder.ComplexType<Address>();
            //modelBuilder.Configurations.Add(new EmployeeMap());
            //modelBuilder.Configurations.Add(new LodgingMap());
            //modelBuilder.Configurations.Add(new DestinationMap());
            //modelBuilder.Configurations.Add(new ReferenceProductConfiguration());
            //modelBuilder.Configurations.Add(new BlogConfiguration());
            //modelBuilder.Configurations.Add(new PostConfiguration());
            //modelBuilder.Configurations.Add(new ActivityMap());
            base.OnModelCreating(modelBuilder);
            // modelBuilder.Conventions.Remove)
        }
Ejemplo n.º 22
0
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove <ManyToManyCascadeDeleteConvention>();

            modelBuilder.Entity <Student>().HasMany(x => x.Courses)
            .WithMany(y => y.Students);

            modelBuilder.Entity <AutomaticTest>().HasMany(x => x.CloseQuestions)
            .WithMany(y => y.AutomaticTests);

            modelBuilder.Entity <Teacher>().HasMany(m => m.Courses);

            modelBuilder.Entity <ManualTest>().HasMany(x => x.CloseQuestions)
            .WithMany(y => y.ManualTests);

            modelBuilder.Entity <ManualTest>().HasMany(x => x.OpenQuestions)
            .WithMany(y => y.ManualTests);

            modelBuilder.Entity <SolvedCloseQuestion>().HasMany(x => x.SelectedAnswers)
            .WithMany();

            modelBuilder.Entity <Student>()
            .HasMany(x => x.CourseLevels).WithMany();

            base.OnModelCreating(modelBuilder);
        }
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            // Database does not pluralize table names
            modelBuilder.Conventions.Remove <PluralizingTableNameConvention>();

            modelBuilder.Entity <PayTo>().HasRequired(x => x.Teammate).WithMany(x => x.PayTos).HasForeignKey(x => x.TeammateId);

            modelBuilder.Entity <Teammate>().HasRequired(x => x.Team).WithMany(x => x.Teammates).HasForeignKey(x => x.TeamId);

            modelBuilder.Entity <Tx>().HasRequired(x => x.Teammate).WithMany().HasForeignKey(x => x.TeammateId);
            modelBuilder.Entity <Tx>().HasOptional(x => x.ClaimTeammate).WithMany().HasForeignKey(x => x.ClaimTeammateId);
            modelBuilder.Entity <Tx>().HasOptional(x => x.MoveToAddress).WithMany(x => x.MoveFundsTxs).HasForeignKey(x => x.MoveToAddressId);

            modelBuilder.Entity <TxInput>().HasRequired(x => x.Tx).WithMany(x => x.Inputs).HasForeignKey(x => x.TxId);

            modelBuilder.Entity <TxOutput>().HasRequired(x => x.Tx).WithMany(x => x.Outputs).HasForeignKey(x => x.TxId);
            modelBuilder.Entity <TxOutput>().HasOptional(x => x.PayTo).WithMany().HasForeignKey(x => x.PayToId);

            modelBuilder.Entity <TxSignature>().HasRequired(x => x.TxInput).WithMany(x => x.Signatures).HasForeignKey(x => x.TxInputId);
            modelBuilder.Entity <TxSignature>().HasRequired(x => x.Teammate).WithMany().HasForeignKey(x => x.TeammateId);

            modelBuilder.Entity <BtcAddress>().HasKey(x => x.Address);
            modelBuilder.Entity <BtcAddress>().HasRequired(x => x.Teammate).WithMany(x => x.Addresses).HasForeignKey(x => x.TeammateId);

            modelBuilder.Entity <Cosigner>().HasKey(x => new { x.AddressId, x.KeyOrder });
            modelBuilder.Entity <Cosigner>().HasRequired(x => x.Address).WithMany(x => x.Cosigners).HasForeignKey(x => x.AddressId);
            modelBuilder.Entity <Cosigner>().HasRequired(x => x.Teammate).WithMany(x => x.CosignerOf).HasForeignKey(x => x.TeammateId);

            modelBuilder.Entity <Disbanding>().HasRequired(x => x.Teammate).WithMany(x => x.Disbandings).HasForeignKey(x => x.TeammateId);

            modelBuilder.Entity <DisbandingTxSignature>().HasRequired(x => x.Cosigner).WithMany(x => x.DisbandingTxSignatures).HasForeignKey(x => new { x.AddressId, x.KeyOrder });
            modelBuilder.Entity <DisbandingTxSignature>().HasRequired(x => x.Address).WithMany().HasForeignKey(x => x.AddressId);
        }
Ejemplo n.º 24
0
 public static System.Data.Entity.DbModelBuilder CreateModel(System.Data.Entity.DbModelBuilder modelBuilder, string schema)
 {
     modelBuilder.Configurations.Add(new AlphabeticalListOfProductConfiguration(schema));
     modelBuilder.Configurations.Add(new CategoryConfiguration(schema));
     modelBuilder.Configurations.Add(new CategorySalesFor1997Configuration(schema));
     modelBuilder.Configurations.Add(new CurrentProductListConfiguration(schema));
     modelBuilder.Configurations.Add(new CustomerConfiguration(schema));
     modelBuilder.Configurations.Add(new CustomerAndSuppliersByCityConfiguration(schema));
     modelBuilder.Configurations.Add(new CustomerDemographicConfiguration(schema));
     modelBuilder.Configurations.Add(new EmployeeConfiguration(schema));
     modelBuilder.Configurations.Add(new InvoiceConfiguration(schema));
     modelBuilder.Configurations.Add(new OrderConfiguration(schema));
     modelBuilder.Configurations.Add(new OrderDetailConfiguration(schema));
     modelBuilder.Configurations.Add(new OrderDetailsExtendedConfiguration(schema));
     modelBuilder.Configurations.Add(new OrdersQryConfiguration(schema));
     modelBuilder.Configurations.Add(new OrderSubtotalConfiguration(schema));
     modelBuilder.Configurations.Add(new ProductConfiguration(schema));
     modelBuilder.Configurations.Add(new ProductsAboveAveragePriceConfiguration(schema));
     modelBuilder.Configurations.Add(new ProductSalesFor1997Configuration(schema));
     modelBuilder.Configurations.Add(new ProductsByCategoryConfiguration(schema));
     modelBuilder.Configurations.Add(new RegionConfiguration(schema));
     modelBuilder.Configurations.Add(new SalesByCategoryConfiguration(schema));
     modelBuilder.Configurations.Add(new SalesTotalsByAmountConfiguration(schema));
     modelBuilder.Configurations.Add(new ShipperConfiguration(schema));
     modelBuilder.Configurations.Add(new SummaryOfSalesByQuarterConfiguration(schema));
     modelBuilder.Configurations.Add(new SummaryOfSalesByYearConfiguration(schema));
     modelBuilder.Configurations.Add(new SupplierConfiguration(schema));
     modelBuilder.Configurations.Add(new TerritoryConfiguration(schema));
     return(modelBuilder);
 }
Ejemplo n.º 25
0
        /// <summary>
        /// This method is called when the model for a derived context has been initialized, but
        /// before the model has been locked down and used to initialize the context.  The default
        /// implementation of this method does nothing, but it can be overridden in a derived class
        /// such that the model can be further configured before it is locked down.
        /// </summary>
        /// <param name="modelBuilder">The builder that defines the model for the context being created.</param>
        /// <remarks>
        /// Typically, this method is called only once when the first instance of a derived context
        /// is created.  The model for that context is then cached and is for all further instances of
        /// the context in the app domain.  This caching can be disabled by setting the ModelCaching
        /// property on the given ModelBuidler, but note that this can seriously degrade performance.
        /// More control over caching is provided through use of the DbModelBuilder and DbContextFactory
        /// classes directly.
        /// </remarks>
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove <PluralizingTableNameConvention>();

            InheritanceMapping(modelBuilder);

            MapEntity <CategoryItemRelation>(modelBuilder, toTable: "CategoryItemRelation");
            MapEntity <ItemAsset>(modelBuilder, toTable: "ItemAsset");
            MapEntity <Association>(modelBuilder, toTable: "Association");
            MapEntity <AssociationGroup>(modelBuilder, toTable: "AssociationGroup");
            MapEntity <CatalogLanguage>(modelBuilder, toTable: "CatalogLanguage");
            MapEntity <EditorialReview>(modelBuilder, toTable: "EditorialReview");
            MapEntity <ItemRelation>(modelBuilder, toTable: "ItemRelation");
            MapEntity <Price>(modelBuilder, toTable: "Price");
            MapEntity <Pricelist>(modelBuilder, toTable: "Pricelist");
            MapEntity <PricelistAssignment>(modelBuilder, toTable: "PricelistAssignment");
            MapEntity <Property>(modelBuilder, toTable: "Property");
            MapEntity <PropertyAttribute>(modelBuilder, toTable: "PropertyAttribute");
            MapEntity <PropertySet>(modelBuilder, toTable: "PropertySet");
            MapEntity <PropertySetProperty>(modelBuilder, toTable: "PropertySetProperty");
            MapEntity <Packaging>(modelBuilder, toTable: "Packaging");
            MapEntity <TaxCategory>(modelBuilder, toTable: "TaxCategory");

            // Introducing FOREIGN KEY constraint 'FK_dbo.Association_dbo.Item_ItemId' on table 'Association' may cause cycles or multiple cascade paths.
            modelBuilder.Entity <Association>().HasRequired(m => m.CatalogItem).WithMany().WillCascadeOnDelete(false);
            modelBuilder.Entity <CategoryItemRelation>().HasRequired(p => p.Category).WithMany().WillCascadeOnDelete(false);
            modelBuilder.Entity <ItemRelation>().HasRequired(m => m.ChildItem).WithMany().WillCascadeOnDelete(false);
            // cascade delete Item and Category when PropertySet is deleted. This should happen ONLY when catalog is being deleted.
            modelBuilder.Entity <Item>().HasOptional(m => m.PropertySet).WithMany().WillCascadeOnDelete(false);
            modelBuilder.Entity <Category>().HasOptional(m => m.PropertySet).WithMany().WillCascadeOnDelete(false);

            base.OnModelCreating(modelBuilder);
        }
Ejemplo n.º 26
0
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Configurations.Add(new AlphabeticalListOfProductConfiguration());
            modelBuilder.Configurations.Add(new CategoryConfiguration());
            modelBuilder.Configurations.Add(new CategorySalesFor1997Configuration());
            modelBuilder.Configurations.Add(new CurrentProductListConfiguration());
            modelBuilder.Configurations.Add(new CustomerConfiguration());
            modelBuilder.Configurations.Add(new CustomerAndSuppliersByCityConfiguration());
            modelBuilder.Configurations.Add(new CustomerDemographicConfiguration());
            modelBuilder.Configurations.Add(new EmployeeConfiguration());
            modelBuilder.Configurations.Add(new InvoiceConfiguration());
            modelBuilder.Configurations.Add(new OrderConfiguration());
            modelBuilder.Configurations.Add(new OrderDetailConfiguration());
            modelBuilder.Configurations.Add(new OrderDetailsExtendedConfiguration());
            modelBuilder.Configurations.Add(new OrdersQryConfiguration());
            modelBuilder.Configurations.Add(new OrderSubtotalConfiguration());
            modelBuilder.Configurations.Add(new ProductConfiguration());
            modelBuilder.Configurations.Add(new ProductsAboveAveragePriceConfiguration());
            modelBuilder.Configurations.Add(new ProductSalesFor1997Configuration());
            modelBuilder.Configurations.Add(new ProductsByCategoryConfiguration());
            modelBuilder.Configurations.Add(new RegionConfiguration());
            modelBuilder.Configurations.Add(new SalesByCategoryConfiguration());
            modelBuilder.Configurations.Add(new SalesTotalsByAmountConfiguration());
            modelBuilder.Configurations.Add(new ShipperConfiguration());
            modelBuilder.Configurations.Add(new SummaryOfSalesByQuarterConfiguration());
            modelBuilder.Configurations.Add(new SummaryOfSalesByYearConfiguration());
            modelBuilder.Configurations.Add(new SupplierConfiguration());
            modelBuilder.Configurations.Add(new TerritoryConfiguration());

            OnModelCreatingPartial(modelBuilder);
        }
Ejemplo n.º 27
0
        /// <inheritdoc />
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            OnModelCreatingImpl(modelBuilder);

            modelBuilder.HasDefaultSchema("dbo");

            modelBuilder.Entity <global::Sandbox_EF6.BaseClass>()
            .ToTable("BaseClasses")
            .HasKey(t => t.Id);
            modelBuilder.Entity <global::Sandbox_EF6.BaseClass>()
            .Property(t => t.Id)
            .IsRequired()
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            modelBuilder.Entity <global::Sandbox_EF6.Detail>()
            .ToTable("Details");
            modelBuilder.Entity <global::Sandbox_EF6.Detail>()
            .HasMany(x => x.BaseClasses)
            .WithRequired()
            .Map(x => x.MapKey("Detail.BaseClasses_Id"));

            modelBuilder.Entity <global::Sandbox_EF6.Master>()
            .ToTable("Masters");
            modelBuilder.Entity <global::Sandbox_EF6.Master>()
            .HasMany(x => x.Details)
            .WithOptional()
            .Map(x => x.MapKey("Master.Details_Id"))
            .WillCascadeOnDelete(true);

            OnModelCreatedImpl(modelBuilder);
        }
Ejemplo n.º 28
0
 protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
 {
     base.OnModelCreating(modelBuilder);
     modelBuilder.Conventions.Remove <System.Data.Entity.ModelConfiguration.Conventions.PluralizingTableNameConvention>();
     modelBuilder.Conventions.Remove <System.Data.Entity.ModelConfiguration.Conventions.OneToManyCascadeDeleteConvention>();
     modelBuilder.Conventions.Remove <System.Data.Entity.ModelConfiguration.Conventions.ManyToManyCascadeDeleteConvention>();
 }
Ejemplo n.º 29
0
        /// <inheritdoc />
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            OnModelCreatingImpl(modelBuilder);

            modelBuilder.HasDefaultSchema("dbo");

            modelBuilder.Entity <global::Sandbox_EF6_Test.Entity1>()
            .ToTable("Entity1")
            .HasKey(t => t.Id);
            modelBuilder.Entity <global::Sandbox_EF6_Test.Entity1>()
            .Property(t => t.Id)
            .IsRequired()
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            modelBuilder.Entity <global::Sandbox_EF6_Test.Entity2>()
            .ToTable("Entity2")
            .HasKey(t => t.Id);
            modelBuilder.Entity <global::Sandbox_EF6_Test.Entity2>()
            .Property(t => t.Id)
            .IsRequired()
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            modelBuilder.Entity <global::Sandbox_EF6_Test.Entity2>()
            .Property(t => t.FK)
            .HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute()));
            modelBuilder.Entity <global::Sandbox_EF6_Test.Entity2>()
            .HasOptional(x => x.Entity1)
            .WithMany(x => x.Entity2)
            .HasForeignKey(p => p.FK);

            OnModelCreatedImpl(modelBuilder);
        }
        /// <summary>
        /// Define the relations between tables
        /// </summary>
        /// <param name="modelBuilder"></param>
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity <ApplicationUser>().HasMany(x => x.SecurityGroups).WithMany(x => x.ApplicationUsers);
            modelBuilder.Entity <ApplicationUser>().HasMany(x => x.Events);

            modelBuilder.Entity <SecurityGroup>().HasMany(x => x.Rights).WithMany();

            modelBuilder.Entity <Organisation>().HasMany(x => x.Items);
            modelBuilder.Entity <Organisation>().HasMany(x => x.Sites);

            modelBuilder.Entity <RequestToAcquireItems>().HasMany(x => x.Items).WithMany();
            modelBuilder.Entity <RequestToAcquireItems>().HasMany(x => x.CountSelectedItems).WithOptional().WillCascadeOnDelete(true);

            modelBuilder.Entity <AssetHistory>().HasKey(x => x.AssetId);
            modelBuilder.Entity <AssetHistory>().HasMany(x => x.Rows);


            modelBuilder.Entity <Site>().HasMany(x => x.Assets);

            modelBuilder.Entity <PackingSlip>().Property(f => f.DateOfGiven).HasColumnType("datetime2");
            modelBuilder.Entity <PackingSlip>().Property(f => f.DateOfReceived).HasColumnType("datetime2");


            modelBuilder.Entity <RequestForAsset>().HasMany(x => x.Assets).WithMany();
            modelBuilder.Entity <RequestForAsset>().HasMany(x => x.ApprovedAssets).WithMany().Map(x => x.ToTable("RequestForAssetApprovedAssets"));
            modelBuilder.Entity <RequestForAsset>().HasMany(x => x.GivenAssets).WithMany().Map(x => x.ToTable("RequestForAssetGivenAssets"));

            modelBuilder.Entity <RequestToProvider>().HasMany(x => x.SendOffers);
            modelBuilder.Entity <RequestToProvider>().HasMany(x => x.WantItems).WithMany();
            modelBuilder.Entity <RequestToProvider>().HasMany(x => x.CountItems);
            modelBuilder.Entity <RequestToProvider>().HasMany(x => x.GiveItems).WithMany().Map(x => x.ToTable("RequesToProviderGiveItems"));

            modelBuilder.Conventions.Remove <ManyToManyCascadeDeleteConvention>();

            modelBuilder.Entity <Invoice>().HasMany(x => x.Items).WithMany();
            modelBuilder.Entity <Invoice>().Property(f => f.DateOfApproving).HasColumnType("datetime2");
            modelBuilder.Entity <Invoice>().Property(f => f.DateOfCreation).HasColumnType("datetime2");
            modelBuilder.Entity <Invoice>().Property(f => f.DateOfPayment).HasColumnType("datetime2");
            modelBuilder.Entity <Invoice>().Property(f => f.PaymentPeriod).HasColumnType("datetime2");


            modelBuilder.Entity <Accident>().Property(f => f.DateOfSend).HasColumnType("datetime2");
            modelBuilder.Entity <Accident>().Property(f => f.ReplyingDate).HasColumnType("datetime2");

            modelBuilder.Entity <Provider>().HasRequired(x => x.Organisation).WithMany()
            .WillCascadeOnDelete(false);

            modelBuilder.Entity <Currency>().HasRequired(x => x.Organisation).WithMany()
            .WillCascadeOnDelete(false);

            modelBuilder.Entity <Location>().HasRequired(x => x.Organisation).WithMany()
            .WillCascadeOnDelete(false);

            modelBuilder.Entity <ExchangeRate>().HasRequired(x => x.Organisation).WithMany()
            .WillCascadeOnDelete(false);


            base.OnModelCreating(modelBuilder);
        }