public void Configure(DbModelBuilder modelBuilder)
        {
            EntityTypeConfiguration <Projection> projectionModel = modelBuilder.Entity <Projection>();

            projectionModel.HasKey(model => model.Id);
            projectionModel.Property(model => model.MovieId).IsRequired();
            projectionModel.Property(model => model.RoomId).IsRequired();
            projectionModel.Property(model => model.StartDate).IsRequired();

            projectionModel
            .HasMany(r => r.Reservations)
            .WithRequired();
            projectionModel
            .HasMany(t => t.Tickets)
            .WithRequired();

            projectionModel
            .HasRequired(m => m.Movie)
            .WithMany(p => p.Projections)
            .HasForeignKey(x => x.MovieId);
            projectionModel
            .HasRequired(r => r.Room)
            .WithMany(p => p.Projections)
            .HasForeignKey(x => x.RoomId);
        }
示例#2
0
        public override void Build(EntityTypeConfiguration <Application> configuration)
        {
            configuration.HasKey(x => x.ID);
            configuration.HasKey(x => x.ID);
            configuration.Property(x => x.ID).HasColumnName("ApplicationID");

            configuration.HasMany(x => x.Consumers)
            .WithMany(x => x.Applications)
            .Map(map =>
            {
                map.ToTable("ConsumersInApplications");
                map.MapLeftKey("ApplicationID");
                map.MapRightKey("ConsumerID");
            });

            configuration.HasMany(x => x.Users)
            .WithMany(x => x.Applications)
            .Map(map =>
            {
                map.ToTable("UsersInApplications");
                map.MapLeftKey("ApplicationID");
                map.MapRightKey("UserID");
            });

            configuration.HasMany(x => x.Permissions)
            .WithRequired(x => x.Application)
            .Map(map => map.MapKey("ApplicationID"));
        }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            if (modelBuilder == null)
            {
                throw new ArgumentNullException("modelBuilder");
            }
            EntityTypeConfiguration <TUser> configuration = modelBuilder.Entity <TUser>().ToTable("Employees");

            configuration.HasMany <TUserRole>(u => u.Roles).WithRequired().HasForeignKey <TKey>(ur => ur.EmployeeId);
            configuration.HasMany <TUserClaim>(u => u.Claims).WithRequired().HasForeignKey <TKey>(uc => uc.EmployeeId);
            configuration.HasMany <TUserLogin>(u => u.Logins).WithRequired().HasForeignKey <TKey>(ul => ul.EmployeeId);
            IndexAttribute indexAttribute = new IndexAttribute("UserNameIndex")
            {
                IsUnique = true
            };

            configuration.Property((Expression <Func <TUser, string> >)(u => u.UserName)).IsRequired().HasMaxLength(0x100).HasColumnAnnotation("Index", new IndexAnnotation(indexAttribute));
            configuration.Property((Expression <Func <TUser, string> >)(u => u.Email)).HasMaxLength(0x100);
            modelBuilder.Entity <TUserRole>().HasKey(r => new { EmployeeId = r.EmployeeId, RoleId = r.RoleId }).ToTable("EmployeeRoles");
            modelBuilder.Entity <TUserLogin>().HasKey(l => new { LoginProvider = l.LoginProvider, ProviderKey = l.ProviderKey, EmployeeId = l.EmployeeId }).ToTable("EmployeeLogins");
            modelBuilder.Entity <TUserClaim>().HasKey(c => new { ClaimType = c.ClaimType, ClaimValue = c.ClaimValue, EmployeeId = c.EmployeeId }).ToTable("EmployeeClaims");
            EntityTypeConfiguration <TRole> configuration2 = modelBuilder.Entity <TRole>().ToTable("Roles");
            IndexAttribute attribute2 = new IndexAttribute("RoleNameIndex")
            {
                IsUnique = true
            };

            configuration2.Property((Expression <Func <TRole, string> >)(r => r.Name)).IsRequired().HasMaxLength(0x100).HasColumnAnnotation("Index", new IndexAnnotation(attribute2));
            configuration2.HasMany <TUserRole>(r => r.Users).WithRequired().HasForeignKey <TKey>(ur => ur.RoleId);
        }
示例#4
0
        public override void Build(EntityTypeConfiguration <Role> configuration)
        {
            configuration.HasKey(x => x.ID);
            configuration.Property(x => x.ID).HasColumnName("RoleID");
            configuration.HasRequired(x => x.Consumer).WithMany(x => x.Roles).Map(m => m.MapKey("ConsumerID"));
            configuration.HasMany(x => x.Permissions)
            .WithMany(x => x.Roles)
            .Map(map =>
            {
                map.ToTable("PermissionsInRoles");
                map.MapLeftKey("RoleID");
                map.MapRightKey("PermissionID");
            });

            configuration.HasMany(x => x.Groups)
            .WithMany(x => x.Roles)
            .Map(map =>
            {
                map.ToTable("RolesInGroups");
                map.MapLeftKey("RoleID");
                map.MapRightKey("GroupID");
            });

            configuration.HasMany(x => x.Users)
            .WithMany(x => x.Roles)
            .Map(map =>
            {
                map.ToTable("UsersInRoles");
                map.MapLeftKey("RoleID");
                map.MapRightKey("UserID");
            });
        }
示例#5
0
 private EntityTypeConfiguration <T> ContentConfiguration <T>(EntityTypeConfiguration <T> configuration) where T : Content
 {
     configuration.Property(e => e.Title).IsRequired();
     configuration.HasMany(e => e.Comments);
     configuration.HasMany(e => e.Tags).WithMany();
     configuration.HasRequired(e => e.WebSite);
     return(configuration);
 }
示例#6
0
 public static void Mapping(EntityTypeConfiguration <User> entityTypeConfiguration)
 {
     entityTypeConfiguration.HasKey(k => k.Id);
     entityTypeConfiguration.Property(p => p.PermissionId);
     entityTypeConfiguration.Property(p => p.FirstName).HasMaxLength(20).HasColumnName("Name").HasColumnType("nvarchar");
     entityTypeConfiguration.Property(p => p.Email).HasMaxLength(100).HasColumnName("Email").HasColumnType("nvarchar");
     entityTypeConfiguration.Property(p => p.Password).HasMaxLength(300).HasColumnName("PassWord").HasColumnType("nvarchar");
     entityTypeConfiguration.HasMany(p => p.Messages);
     entityTypeConfiguration.HasMany(p => p.Files);
     entityTypeConfiguration.HasMany(p => p.Stickers);
 }
示例#7
0
        private void ConfigurePosts(EntityTypeConfiguration <Post> entityTypeConfiguration)
        {
            entityTypeConfiguration
            .HasMany(p => p.Comments)
            .WithRequired(c => c.Post)
            .HasForeignKey(c => c.PostId);

            entityTypeConfiguration
            .HasMany(p => p.Reactions)
            .WithRequired(r => r.Post);
        }
        public override IEdmModel GetEdmModel()
        {
            Namespace = "WidgetData";               // Hide Model Schema from $metadata

            EntityTypeConfiguration <Domain.Widget> WidgetConfiguration = EntitySet <Domain.Widget>("Widget").EntityType;

            WidgetConfiguration
            .HasKey(e => e.WidgetId)
            .Filter()                       // Allow for the $filter Command
            .Count()                        // Allow for the $count Command
            .Expand()                       // Allow for the $expand Command
            .OrderBy()                      // Allow for the $orderby Command
            .Page()                         // Allow for the $top and $skip Commands
            .Select();                      // Allow for the $select Command;
            WidgetConfiguration.HasMany(e => e.Part);

            EntityTypeConfiguration <Domain.WidgetPart> WidgetPartConfiguration = EntityType <Domain.WidgetPart>();

            WidgetPartConfiguration.HasKey(e => new { e.WidgetId, e.PartId, e.BlueprintId });

            EntityTypeConfiguration <Domain.Supplier> SupplierConfiguration = EntitySet <Domain.Supplier>("Supplier").EntityType;

            SupplierConfiguration
            .HasKey(e => e.SupplierId)
            .Filter()                       // Allow for the $filter Command
            .Count()                        // Allow for the $count Command
            .Expand()                       // Allow for the $expand Command
            .OrderBy()                      // Allow for the $orderby Command
            .Page()                         // Allow for the $top and $skip Commands
            .Select();                      // Allow for the $select Command;
            SupplierConfiguration.HasMany(e => e.Part);

            EntityTypeConfiguration <Domain.SupplierPart> SupplierPartConfiguration = EntityType <Domain.SupplierPart>();

            SupplierPartConfiguration.HasKey(e => new { e.SupplierId, e.PartId });

            EntityTypeConfiguration <Domain.Part> PartConfiguration = EntitySet <Domain.Part>("Part").EntityType;

            PartConfiguration
            .HasKey(e => e.PartId)
            .Filter()                       // Allow for the $filter Command
            .Count()                        // Allow for the $count Command
            .Expand()                       // Allow for the $expand Command
            .OrderBy()                      // Allow for the $orderby Command
            .Page()                         // Allow for the $top and $skip Commands
            .Select();                      // Allow for the $select Command;
            PartConfiguration.HasMany(e => e.Supplier);
            PartConfiguration.HasMany(e => e.Widget);

            return(base.GetEdmModel());
        }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            if (modelBuilder == null)
            {
                throw new ArgumentNullException("modelBuilder");
            }

            base.OnModelCreating(modelBuilder);

            //配置permission与rolePermission的1对多关系
            EntityTypeConfiguration <ApplicationPermission> configuration = modelBuilder.Entity <ApplicationPermission>().ToTable("ApplicationPermissions");

            configuration.HasMany <ApplicationRolePermission>(u => u.Roles).WithRequired().HasForeignKey(k => k.PermissionId);
            //配置role与persmission的映射表RolePermission的键
            modelBuilder.Entity <ApplicationRolePermission>().HasKey(r => new { PermissionId = r.PermissionId, RoleId = r.RoleId }).ToTable("RolePermissions");
            //配置role与RolePermission的1对多关系
            EntityTypeConfiguration <ApplicationRole> configuration2 = modelBuilder.Entity <ApplicationRole>();

            configuration2.HasMany <ApplicationRolePermission>(r => r.Permissions).WithRequired().HasForeignKey(k => k.RoleId);

            //配置Department与applicationUser的多对多关系
            modelBuilder.Entity <UserDepartment>().HasKey(u => new { u.ApplicationUserId, u.DepartmentId }).ToTable("UserDepartment").Property(t => t.ApplicationUserId).HasColumnName("UserId");

            EntityTypeConfiguration <Department> configuration3 = modelBuilder.Entity <Department>();

            configuration3.HasMany(d => d.Users).WithRequired().HasForeignKey(k => k.DepartmentId);

            EntityTypeConfiguration <ApplicationUser> configuration4 = modelBuilder.Entity <ApplicationUser>();

            configuration4.HasMany(d => d.Departments).WithOptional().HasForeignKey(k => k.ApplicationUserId);
        }
示例#10
0
 public static ManyNavigationPropertyConfiguration <TEntityType, TTargetEntityType> HasMany <TEntityType, TTargetEntityType>(this EntityTypeConfiguration <TEntityType> mapper, string propertyName)
     where TEntityType : class
     where TTargetEntityType : class
 {
     // NB: this cast will blow up at runtime (i.e. during entity mapper setup) if the nominated property is not of type ICollection<TTargetEntityType>
     return(mapper.HasMany((Expression <Func <TEntityType, ICollection <TTargetEntityType> > >) typeof(TEntityType).GetPropertyAccessExpression(propertyName)));
 }
示例#11
0
 /// <summary>
 /// 映射动作。
 /// </summary>
 /// <param name="configuration">实体类型配置对象。</param>
 public override void Mapping(EntityTypeConfiguration <PostRecord> configuration)
 {
     configuration
     .HasMany(i => i.Categorys)
     .WithMany(i => i.Posts)
     .Map(i => i.ToTable("PostCategoryRecordPostRecords"));
 }
示例#12
0
        public static void Map(EntityTypeConfiguration <Status> config)
        {
            config.HasKey(m => m.Id);
            config.Property(m => m.Name).HasColumnType("varchar").HasColumnName("Name").IsRequired();

            config.HasMany(m => m.Objectives);
        }
示例#13
0
        public static void Map(EntityTypeConfiguration <Genre> config)
        {
            config.HasKey(m => m.Id);
            config.Property(m => m.Title).HasMaxLength(20).HasColumnType("varchar").HasColumnName("Title").IsRequired();

            config.HasMany(m => m.Books);
        }
示例#14
0
        protected void buildOrders(EntityTypeConfiguration <Order> orderEntity)
        {
            orderEntity
            .HasKey(x => x.orderID)
            .Property(x => x.orderDate)
            .IsRequired();

            orderEntity
            .Property(x => x.status)
            .IsRequired();

            orderEntity
            .Property(x => x.address)
            .IsRequired()
            .HasMaxLength(400);

            orderEntity
            .Property(x => x.timeStamp)
            .IsRequired();

            orderEntity
            .HasRequired(x => x.customer)
            .WithMany(x => x.orders);
            orderEntity
            .HasMany(x => x.products)
            .WithRequired(x => x.order)
            .WillCascadeOnDelete();
        }
示例#15
0
 public TreeTypeBuilder(EntityTypeConfiguration <TreeType> entity)
 {
     entity.Property(p => p.Name).IsRequired().HasMaxLength(200);
     entity.Property(p => p.Photo).IsRequired().HasMaxLength(200);
     //  entity.HasRequired(p => p.Region).WithMany(m => m.TreeTypes).HasForeignKey(p => p.RegionId).WillCascadeOnDelete(false);
     entity.HasMany(t => t.treeTypes).WithMany(r => r.Regions);
 }
        /// <summary>
        /// Extension method for map private navigation property
        /// <example>
        ///  modelBuilder.Entity<Customer>()
        ///              .HasMany<Customer, Order>("Orders");
        /// </example>
        /// </summary>
        /// <typeparam name="TEntityType">The type of principal entity</typeparam>
        /// <typeparam name="TTargetEntityType">The type of target entity (without ICollection{})</typeparam>
        /// <param name="entityConfiguration">Associated EntityTypeConfiguration</param>
        /// <param name="navigationPropertyName">The navigation property name</param>
        /// <returns>The ManyNavigationPropertyConfiguration for this map</returns>
        public static ManyNavigationPropertyConfiguration <TEntityType, TTargetEntityType> HasMany <TEntityType, TTargetEntityType>(this EntityTypeConfiguration <TEntityType> entityConfiguration, string navigationPropertyName)
            where TEntityType : class
            where TTargetEntityType : class
        {
            var propertyInfo = typeof(TEntityType).GetProperty(navigationPropertyName,
                                                               BindingFlags.NonPublic |
                                                               BindingFlags.Instance |
                                                               BindingFlags.Public);

            if (propertyInfo != null) // if private property exists
            {
                ParameterExpression arg = Expression.Parameter(typeof(TEntityType), "parameterName");
                MemberExpression    memberExpression = Expression.Property((Expression)arg, propertyInfo);

                //Create the expression to map
                Expression <Func <TEntityType, ICollection <TTargetEntityType> > > expression = (Expression <Func <TEntityType, ICollection <TTargetEntityType> > >)Expression.Lambda(memberExpression, arg);


                return(entityConfiguration.HasMany <TTargetEntityType>(expression));
            }
            else
            {
                throw new InvalidOperationException("The property not exist");
            }
        }
示例#17
0
 public static void Map(EntityTypeConfiguration <Transaction> config)
 {
     config.ToTable("EF_Transaction");
     config.HasKey(r => r.TransactionId);
     config.HasMany(r => r.ItemTransactions)
     .WithRequired(r => r.Transaction)
     .WillCascadeOnDelete(false);
 }
示例#18
0
        public void Configure(EntityTypeConfiguration <Person> config)
        {
            config.HasKey(x => x.Id);
            config.HasMany(x => x.Cars).WithRequired(x => x.Owner);
            config.HasOptional(x => x.Address).WithRequired(x => x.Person);

            new TrackedEntityConfiguration <Person>().Configure(config);
        }
示例#19
0
        internal static void OnModelCreating(EntityTypeConfiguration <Module> entityTypeConfiguration)
        {
            entityTypeConfiguration.HasMany(i => i.Packets)
            .WithRequired(i => i.Module);

            entityTypeConfiguration.HasMany(i => i.Messages)
            .WithOptional(i => i.Module);

            entityTypeConfiguration.HasMany(i => i.TemperatureSensors)
            .WithRequired(i => i.Module);

            entityTypeConfiguration.HasMany(i => i.VoltageReadings)
            .WithRequired(i => i.Module);

            entityTypeConfiguration.HasMany(i => i.ModuleFunctions)
            .WithRequired(i => i.Module);
        }
        public static void BuildModel(DbModelBuilder modelBuilder)
        {
            ConfigureConventions(modelBuilder);
            ConfigureRelations(modelBuilder);
            ConfigureConstraints(modelBuilder);

            EntityTypeConfiguration <User> userConfiguration = modelBuilder.Entity <User>().ToTable("User");

            userConfiguration.HasMany(u => u.UserRoles).WithRequired().HasForeignKey(role => role.UserId);
            userConfiguration.HasMany(u => u.Claims).WithRequired().HasForeignKey(claim => claim.UserId);
            userConfiguration.HasMany(u => u.Logins).WithRequired().HasForeignKey(login => login.UserId);

            StringPropertyConfiguration propertyUserNameConfiguration = userConfiguration.Property(u => u.UserName).IsRequired().HasMaxLength(256);
            string         annotationUserName = "******";
            IndexAttribute annotationUserNameIndexAttribute = new IndexAttribute("UserNameIndex")
            {
                IsUnique = true
            };
            IndexAnnotation annotationUserNameIndex = new IndexAnnotation(annotationUserNameIndexAttribute);

            propertyUserNameConfiguration.HasColumnAnnotation(annotationUserName, annotationUserNameIndex);

            userConfiguration.Property(u => u.Email).HasMaxLength(256);

            modelBuilder.Entity <UserRole>().HasKey(role => new { role.UserId, role.RoleId });
            modelBuilder.Entity <UserRole>().ToTable("UsersRoles");

            modelBuilder.Entity <UserLogin>().HasKey(login => new { login.LoginProvider, login.ProviderKey, login.UserId });
            modelBuilder.Entity <UserLogin>().ToTable("UserLogin");

            modelBuilder.Entity <UserClaim>().ToTable("UserClaim");

            EntityTypeConfiguration <Role> roleConfiguration         = modelBuilder.Entity <Role>().ToTable("Role");
            StringPropertyConfiguration    propertyNameConfiguration = roleConfiguration.Property(r => r.Name).IsRequired().HasMaxLength(256);
            string         annotationName = "Index";
            IndexAttribute annotationNameIndexAttribute = new IndexAttribute("RoleNameIndex")
            {
                IsUnique = true
            };
            IndexAnnotation annotationNameIndex = new IndexAnnotation(annotationNameIndexAttribute);

            propertyNameConfiguration.HasColumnAnnotation(annotationName, annotationNameIndex);

            roleConfiguration.HasMany(role => role.UserRoles).WithRequired().HasForeignKey(userRole => userRole.RoleId);
        }
示例#21
0
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            if (modelBuilder == null)
            {
                throw new ArgumentNullException("ModelBuilder is NULL");
            }

            //base.OnModelCreating(modelBuilder);
            EntityTypeConfiguration <IdentityUser> table = modelBuilder.Entity <IdentityUser>().ToTable("AspNetUsers2");

            table.HasMany <IdentityUserRole>((IdentityUser u) => u.Roles).WithRequired().HasForeignKey <string>((IdentityUserRole ur) => ur.UserId);
            table.HasMany <IdentityUserClaim>((IdentityUser u) => u.Claims).WithRequired().HasForeignKey <string>((IdentityUserClaim uc) => uc.UserId);
            table.HasMany <IdentityUserLogin>((IdentityUser u) => u.Logins).WithRequired().HasForeignKey <string>((IdentityUserLogin ul) => ul.UserId);
            StringPropertyConfiguration stringPropertyConfiguration = table.Property((IdentityUser u) => u.UserName).IsRequired().HasMaxLength(new int?(256));
            IndexAttribute indexAttribute = new IndexAttribute("UserNameIndex")
            {
                IsUnique = true
            };

            stringPropertyConfiguration.HasColumnAnnotation("Index", new IndexAnnotation(indexAttribute));
            table.Property((IdentityUser u) => u.Email).HasMaxLength(new int?(256));

            modelBuilder.Entity <IdentityUserRole>().HasKey((IdentityUserRole r) => new { UserId = r.UserId, RoleId = r.RoleId }).ToTable("AspNetUserRoles2");
            modelBuilder.Entity <IdentityUserLogin>().HasKey((IdentityUserLogin l) => new { LoginProvider = l.LoginProvider, ProviderKey = l.ProviderKey, UserId = l.UserId }).ToTable("AspNetUserLogins2");
            modelBuilder.Entity <IdentityUserClaim>().ToTable("AspNetUserClaims2");

            EntityTypeConfiguration <IdentityRole> entityTypeConfiguration      = modelBuilder.Entity <IdentityRole>().ToTable("AspNetRoles2");
            StringPropertyConfiguration            stringPropertyConfiguration1 = entityTypeConfiguration.Property((IdentityRole r) => r.Name).IsRequired().HasMaxLength(new int?(256));
            IndexAttribute indexAttribute1 = new IndexAttribute("RoleNameIndex")
            {
                IsUnique = true
            };

            stringPropertyConfiguration1.HasColumnAnnotation("Index", new IndexAnnotation(indexAttribute1));
            entityTypeConfiguration.HasMany <IdentityUserRole>((IdentityRole r) => r.Users).WithRequired().HasForeignKey <string>((IdentityUserRole ur) => ur.RoleId);



            /* //Defining the keys and relations
             * modelBuilder.Entity<ApplicationUser>().ToTable("SecUsuario");
             * modelBuilder.Entity<ApplicationRole>().HasKey<string>(r => r.Id).ToTable("SecRol");
             * modelBuilder.Entity<ApplicationUser>().HasMany<ApplicationUserRole>((ApplicationUser u) => u.UserRoles);
             * modelBuilder.Entity<ApplicationUserRole>().HasKey(r => new { UserId = r.UserId, RoleId = r.RoleId }).ToTable("SecRolUsuario");
             */
        }
示例#22
0
 public static void Map(EntityTypeConfiguration <ItemTransaction> config)
 {
     config.ToTable("EF_ItemTransaction");
     config.HasKey(r => new { r.TransactionId, r.IndexNo });
     config.HasMany(r => r.ItemTransactionCharges)
     .WithRequired(r => r.ItemTransaction)
     .WillCascadeOnDelete(false);
     config.HasOptional(r => r.Item);
 }
示例#23
0
        private void MapRole(EntityTypeConfiguration <Role> role)
        {
            role.HasKey(i => i.Id).ToTable("Roles");

            role.Property(i => i.Id).HasColumnName("ID").HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            role.Property(i => i.Name).IsRequired();

            role.HasMany(t => t.Users).WithMany().Map(m => m.MapLeftKey("FKRoleID").MapRightKey("FKUserID").ToTable("UserRoles"));
        }
示例#24
0
 private void BuildChatRoom(EntityTypeConfiguration <ChatRoom> entity)
 {
     entity.HasMany(e => e.Users)
     .WithMany(t => t.ChatRooms)
     .Map(map =>
     {
         map.MapRightKey("ChatRoomId");
         map.MapLeftKey("UserId");
         map.ToTable("UserChatRooms");
     });
 }
示例#25
0
        internal static void OnModelCreating(EntityTypeConfiguration <TemperatureSensor> entityTypeConfiguration)
        {
            entityTypeConfiguration.Property(i => i.Period).HasPrecision(1);

            entityTypeConfiguration.HasRequired(i => i.Module)
            .WithMany(i => i.TemperatureSensors)
            .HasForeignKey(i => i.ModuleID);

            entityTypeConfiguration.HasMany(i => i.TemperatureReadings)
            .WithRequired(i => i.TemperatureSensor);
        }
 static void ConfigureContinent(EntityTypeConfiguration <Continent> entity)
 {
     entity.Property(p => p.Name).IsUnicode(false).HasMaxLength(100);
     entity.HasIndex(e => e.Name);
     entity.Property(e => e.Name).IsConcurrencyToken();
     entity
     .HasMany(c => c.Countries)
     .WithOptional(c => c.Continent)
     .HasForeignKey(c => c.ContinentId)
     .WillCascadeOnDelete(true);
     entity.MapToStoredProcedures();
 }
        public void Configure(DbModelBuilder modelBuilder)
        {
            EntityTypeConfiguration <Cinema> cinemaModel = modelBuilder.Entity <Cinema>();

            cinemaModel.HasKey(model => model.Id);
            cinemaModel.Property(model => model.Name).IsRequired();
            cinemaModel.Property(model => model.Address).IsRequired();

            cinemaModel
            .HasMany(r => r.Rooms)
            .WithRequired();
        }
示例#28
0
        public EmployeeBuilder(EntityTypeConfiguration <Employee> entity)
        {
            entity.HasKey(p => p.Id);
            entity.Property(p => p.FirstName).IsRequired().HasMaxLength(100);
            entity.Property(p => p.LastName).IsRequired().HasMaxLength(100);
            entity.Property(p => p.UserName).IsRequired().HasMaxLength(200);
            entity.Property(p => p.Position).IsRequired().HasMaxLength(200);

            entity.HasMany(p => p.Departments).WithMany(w => w.Employees);
            entity.HasOptional(p => p.Company).WithMany(w => w.Employees).HasForeignKey(p => p.CompanyId); // bunu da silmek gerekicek.
            entity.HasOptional(p => p.Branch).WithMany(w => w.Employees).HasForeignKey(p => p.BranchId);
        }
        public void Configure(DbModelBuilder modelBuilder)
        {
            EntityTypeConfiguration <Movie> movieModel = modelBuilder.Entity <Movie>();

            movieModel.HasKey(model => model.Id);
            movieModel.Property(model => model.Name).IsRequired();
            movieModel.Property(model => model.DurationMinutes).IsRequired();

            movieModel
            .HasMany(p => p.Projections)
            .WithRequired();
        }
示例#30
0
 private B4USContext MapSchedule(EntityTypeConfiguration <Schedule> configuration)
 {
     configuration
     .HasMany(location => location.Services)
     .WithMany(service => service.Locations)
     .Map(config =>
     {
         config.ToTable("servicetoloc");
         config.MapLeftKey("LocID");
         config.MapRightKey("ServiceId");
     });
     return(this);
 }
示例#31
0
        protected void buildCustomers(EntityTypeConfiguration<Customer> customerEntity)
        {
            customerEntity
                .HasKey(x => x.customerID)
                .Property(x => x.name).IsRequired()
                .HasMaxLength(50);

            customerEntity
                .HasMany(x => x.orders)
                .WithRequired(x => x.customer)
                .HasForeignKey(x => x.customerID)
                .WillCascadeOnDelete();

            customerEntity
                .Property(x => x.timeStamp)
                .IsRequired();
        }
示例#32
0
        /// <summary>
        /// Configure LongShortUrl entityTypeConfiguration
        /// </summary>
        /// <param name="modelBuilder"></param>
        private static void configureEntity(EntityTypeConfiguration<LongShortUrl> entityTypeConfiguration)
        {
            entityTypeConfiguration.HasKey(e => e.Id);

            entityTypeConfiguration.Property(e => e.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            entityTypeConfiguration.Property(e => e.ShortUrlId).IsRequired().HasMaxLength(10);

            entityTypeConfiguration.Property(e => e.LongUrl).IsRequired().HasMaxLength(2000);

            entityTypeConfiguration.Property(e => e.CreatedDate).IsRequired();

            entityTypeConfiguration
                .HasMany(e => e.LongShortUrlUsers)
                .WithOptional()
                .HasForeignKey(e => e.LongShortUrlId)
                .WillCascadeOnDelete();

        }
示例#33
0
文件: Dish.cs 项目: kissarat/dandy
 public static void Configurate(EntityTypeConfiguration<Dish> config)
 {
     config.HasMany(e => e.Delicious).WithMany()
     .Map(m => m.ToTable("Delicious"));
 }
        protected override void MapPerson(EntityTypeConfiguration<Person> config)
        {
            base.MapPerson(config);

            config.HasMany(p => p.Kjøp).WithRequired(k => k.Person);
        }
示例#35
0
        protected void buildOrders(EntityTypeConfiguration<Order> orderEntity)
        {
            orderEntity
                .HasKey(x => x.orderID)
                .Property(x => x.orderDate)
                .IsRequired();

            orderEntity
                .Property(x => x.status)
                .IsRequired();

            orderEntity
                .Property(x => x.address)
                .IsRequired()
                .HasMaxLength(400);

            orderEntity
                .Property(x => x.timeStamp)
                .IsRequired();

            orderEntity
                .HasRequired(x => x.customer)
                .WithMany(x => x.orders);
            orderEntity
                .HasMany(x => x.products)
                .WithRequired(x => x.order)
                .WillCascadeOnDelete();
        }
示例#36
0
        protected void buildProducts(EntityTypeConfiguration<Product> productEntity)
        {
            productEntity
                .HasKey(x => x.productID)
                .Property(x => x.name)
                .HasMaxLength(50);

            productEntity
                .Property(x => x.price)
                .IsRequired();

            productEntity
                .Property(x => x.timeStamp)
                .IsRequired();

            productEntity
                .HasMany(x => x.files)
                .WithRequired(x => x.product)
                .HasForeignKey(x => x.productID)
                .WillCascadeOnDelete();
        }