本文整理汇总了C#中DbModelBuilder.Ignore方法的典型用法代码示例。如果您正苦于以下问题:C# DbModelBuilder.Ignore方法的具体用法?C# DbModelBuilder.Ignore怎么用?C# DbModelBuilder.Ignore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbModelBuilder
的用法示例。
在下文中一共展示了DbModelBuilder.Ignore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnModelCreating
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.Ignore<IIdentifiableEntity>();
modelBuilder.Ignore<IObjectWithState>();
// Had to explicitly ignore the EntityId also as below..
//Specify the Primary Key as well in the below
//Society Schemas
modelBuilder.Entity<Building>().ToTable("Building", "Society").HasKey<Guid>(e => e.Id).Ignore(e => e.EntityId).Ignore(e=>e.ObjectState);
modelBuilder.Entity<House>().ToTable("House", "Society").HasKey<Guid>(e => e.Id).Ignore(e => e.EntityId).Ignore(e => e.ObjectState);
modelBuilder.Entity<Society>().ToTable("Society", "Society").HasKey<Guid>(e => e.Id).Ignore(e => e.EntityId).Ignore(e => e.ObjectState);
//Making surer the Code is the identity Column
modelBuilder.Entity<Society>().ToTable("Society", "Society").Property(p => p.Code).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
//Security Schemas
// UserId is the identity column.
modelBuilder.Entity<Resident>().ToTable("Resident", "Security").HasKey<Guid>(e => e.Id).Ignore(e => e.EntityId)
.Property(p=>p.UserId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
modelBuilder.Entity<ResidentSocietyMapping>().ToTable("ResidentSocietyMapping", "Security").HasKey<Guid>(e => e.Id).Ignore(e => e.EntityId).Ignore(e => e.ObjectState);
modelBuilder.Entity<ResidentSocietyRoleMapping>().ToTable("ResidentSocietyRoleMapping", "Security").HasKey<Guid>(e => e.Id).Ignore(e => e.EntityId).Ignore(e => e.ObjectState);
modelBuilder.Entity<Role>().ToTable("Role", "Security").HasKey<Guid>(e => e.Id).Ignore(e => e.EntityId);
modelBuilder.Entity<SocietyRolePrivilege>().ToTable("SocietyRolePrivilege", "Security").HasKey<Guid>(e => e.Id).Ignore(e => e.EntityId).Ignore(e => e.ObjectState);
//Instance Schemas
modelBuilder.Entity<Audit>().ToTable("Audit", "Instance").HasKey<Guid>(e => e.Id).Ignore(e => e.EntityId);
}
示例2: QuitarVolkswagenDelContext
protected void QuitarVolkswagenDelContext(DbModelBuilder modelBuilder)
{
modelBuilder.Ignore<InformeInspeccionVolkswagen>();
modelBuilder.Ignore<DetalleInformeInspeccionVolkswagen>();
modelBuilder.Ignore<InformeInspeccionVolkswagenCompleto>();
modelBuilder.Ignore<DetalleInformeInspeccionVolkswagenCompleto>();
}
示例3: OnModelCreating
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
Logger.Info("OnModelCreating entered");
modelBuilder.Ignore<PropertyChangedEventHandler>();
modelBuilder.Ignore<ExtensionDataObject>();
modelBuilder.Ignore<IIdentifiableEntity>();
modelBuilder.Entity<Supplier>().HasKey<int>(e => e.Id).Ignore(e => e.EntityId);
modelBuilder.Entity<Stock>().HasKey<int>(e => e.Id).Ignore(e => e.EntityId);
modelBuilder.Entity<Part>().HasKey<int>(e => e.Id).Ignore(e => e.EntityId);
modelBuilder.Entity<Part>().Ignore(e => e.Components);
modelBuilder.Entity<Part>().Ignore(e => e.Suppliers);
modelBuilder.Entity<Part>().Property(o => o.OwnCost).HasPrecision(25, 13);
modelBuilder.Entity<Part>().Property(o => o.ComponentsCost).HasPrecision(25, 13);
modelBuilder.Entity<Subassembly>().HasKey<int>(e => e.Id).Ignore(e => e.EntityId);
modelBuilder.Entity<Subassembly>().Ignore(e => e.PartDescription);
modelBuilder.Entity<Subassembly>().Property(o => o.CostContribution).HasPrecision(25, 13);
modelBuilder.Entity<Subassembly>().Property(o => o.InheritedCost).HasPrecision(25, 13);
modelBuilder.Entity<Subassembly>().Property(o => o.Demand).HasPrecision(25, 13);
modelBuilder.Entity<Order>().HasKey<int>(e => e.Id).Ignore(e => e.EntityId);
modelBuilder.Entity<Order>().Ignore(e => e.Items);
//ToDo establish relationship by OrderID
modelBuilder.Entity<OrderDetail>().HasKey<int>(e => e.Id).Ignore(e => e.EntityId);
modelBuilder.Entity<OrderDetail>().Property(o => o.Price).HasPrecision(10, 2);
modelBuilder.Entity<OrderDetail>().Ignore(e => e.PartDescription);
}
示例4: OnModelCreating
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
/*
* Таблицы сущностей в БД могут называться лишь идентично самим сущностям!
* Убираем создание множества названий таблиц (конвенцию)
* AccountSet != Account != Accounts ...
*/
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
/*
* В БД нет колонки для ExtensionDataObject, но она есть в каждой сущности,
* потому что все сущности унаследованы от EntityBase.
* Также все сущности реализуют ин-с IIdentifiableEntity, для которого тоже нет колонки в БД.
*
* Ин-с IAccountOwnedEntity реализован ЯВНО => его члены не воспринимаются как свойства класса.
*/
modelBuilder.Ignore<ExtensionDataObject>();
modelBuilder.Ignore<IIdentifiableEntity>();
/*
* Назначаем ключевые поля сущностей в таблицах БД
*
* + он говорит сделать так: modelBuilder.Entity<Account>().HasKey<int>(e => e.AccountId).Ignore(e => e.EntityId);
* так как почему-то на него руганулась IDE, хотя он добавил исключение выше: modelBuilder.Ignore<IIdentifiableEntity>()
*/
modelBuilder.Entity<Account>().HasKey<int>(e => e.AccountId);
modelBuilder.Entity<Car>().HasKey<int>(e => e.CarId);
modelBuilder.Entity<Rental>().HasKey<int>(e => e.RentalId);
modelBuilder.Entity<Reservation>().HasKey<int>(e => e.ReservationId);
// Этого свойства нет в БД. Оно используется только внутри программы для подсчетов
modelBuilder.Entity<Car>().Ignore<bool>(e => e.CurrentlyRented);
}
示例5: EFDbContext
//Set up the connection using the Constructor
public EFDbContext()
: base("name=EmployeeProjectsDbContext")
{
//Stop EF from automatically mapping to a missing "Customer" table
DbModelBuilder objDBMB = new DbModelBuilder();
objDBMB.Ignore<Employee>();
objDBMB.Ignore<Project>();
objDBMB.Ignore<EmployeeProjectHour>();
objDBMB.Ignore<ValidHourEntry>();
objDBMB.Ignore<ThisYearsDate>();
}
示例6: OnModelCreating
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.Ignore<ExtensionDataObject>();
modelBuilder.Ignore<IIdentifiableEntity>();
modelBuilder.Entity<Account>().HasKey<int>(e => e.AccountId).Ignore(e => e.EntityId).Ignore(e => e.OwnerAccountId);
modelBuilder.Entity<Car>().HasKey<int>(e => e.CarId).Ignore(e => e.EntityId);
modelBuilder.Entity<Rental>().HasKey<int>(e => e.RentalId).Ignore(e => e.EntityId).Ignore(e => e.OwnerAccountId);
modelBuilder.Entity<Reservation>().HasKey<int>(e => e.ReservationId).Ignore(e => e.EntityId).Ignore(e => e.OwnerAccountId);
modelBuilder.Entity<Car>().Ignore(e => e.CurrentlyRented);
}
示例7: OnModelCreating
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.Ignore<PropertyChangedEventHandler>();
modelBuilder.Ignore<ExtensionDataObject>();
modelBuilder.Ignore<IIdentifiableEntity>();
modelBuilder.Entity<Style>().HasKey<int>(e => e.MerretStyleID).Ignore(e => e.EntityId);
modelBuilder.Entity<Product>().HasKey<int>(e => e.AccountId).Ignore(e => e.EntityId);
modelBuilder.Entity<Account>().HasKey<int>(e => e.AccountId).Ignore(e => e.EntityId);
}
示例8: OnModelCreating
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.Conventions.Remove<ForeignKeyDiscoveryConvention>();
modelBuilder.Ignore<ExtensionDataObject>();
modelBuilder.Ignore<IIdentifiableEntity>();
modelBuilder.Entity<Doctor>().HasKey<int>(e => e.Id).Ignore(e=>e.EntityId);
modelBuilder.Entity<MedicalSpecialization>().HasKey<int>(e => e.Id).Ignore(e => e.EntityId);
modelBuilder.Entity<Account>().HasKey<int>(e => e.AccountId).Ignore(e => e.EntityId);
modelBuilder.Entity<DoctorNonAvailabilty>().HasKey<int>(e => e.Id).Ignore(e => e.EntityId);
modelBuilder.Entity<Appointment>().HasKey<int>(e => e.AppointmentId).Ignore(e => e.EntityId);
}
示例9: OnModelCreating
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.Ignore<PropertyChangedEventHandler>();
modelBuilder.Ignore<ExtensionDataObject>();
modelBuilder.Ignore<IIdentifiableEntity>();
modelBuilder.Entity<Account>().HasKey<int>(e => e.AccountId).Ignore(e => e.EntityId);
modelBuilder.Entity<TimeSlot>().HasKey<int>(e => e.TimeSlotId).Ignore(e => e.EntityId);
modelBuilder.Entity<Appointment>().HasKey<int>(e => e.AppointmentId).Ignore(e => e.EntityId);
modelBuilder.Entity<Reservation>().HasKey<int>(e => e.ReservationId).Ignore(e => e.EntityId);
modelBuilder.Entity<TimeSlot>().Ignore(e => e.CurrentlyBooked);
}
示例10: OnModelCreating
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add(new UserConfiguration());
modelBuilder.Configurations.Add(new AccountConfiguration());
modelBuilder.Configurations.Add(new PurchaseConfiguration());
modelBuilder.Configurations.Add(new CategoryConfiguration());
modelBuilder.Ignore<IdentityUserClaim>();
modelBuilder.Ignore<IdentityUserLogin>();
modelBuilder.Ignore<IdentityUserRole>();
modelBuilder.Ignore<IdentityRole>();
base.OnModelCreating(modelBuilder);
}
示例11: OnModelCreating
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.Ignore<PosManagerEntity>();
modelBuilder.Entity<SaleOperation>().Property(e => e.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
modelBuilder.Entity<Customer>().Property(e => e.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
modelBuilder.Entity<Product>().Property(e => e.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
modelBuilder.Entity<User>().Property(e => e.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
modelBuilder.Entity<Locale>().Property(e => e.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
modelBuilder.Entity<Translation>().Property(e => e.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
modelBuilder.Entity<PlanType>().Property(e => e.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
modelBuilder.Entity<Plan>().Property(e => e.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
modelBuilder.Entity<DiscountType>().Property(e => e.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
modelBuilder.Entity<Discount>().Property(e => e.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
//modelBuilder.Entity<Cart>()
//.HasMany(c => c.Products)
//.WithMany()
//.Map(m =>
//{
// m.MapLeftKey("CartId");
// m.MapRightKey("ProductID");
// m.ToTable("CartProducts");
//});
}
示例12: OnModelCreating
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Customer>().ToTable("Customers");
modelBuilder.Entity<CompanyPerson>().ToTable("CompanyPersons");
modelBuilder.Ignore<Person>();
modelBuilder.Entity<Company>().Property(p => p.Name).IsRequired().HasMaxLength(60);
modelBuilder.Entity<Company>().Property(p => p.Description).HasMaxLength(500);
modelBuilder.Entity<Deal>().Property(p => p.Name).IsRequired().HasMaxLength(60);
modelBuilder.Entity<Deal>().Property(p => p.Description).HasMaxLength(500);
modelBuilder.Entity<Address>().Property(p => p.City).HasMaxLength(60);
modelBuilder.Entity<Address>().Property(p => p.PostalNumber).HasMaxLength(6);
modelBuilder.Entity<Address>().Property(p => p.Street).HasMaxLength(60);
modelBuilder.Entity<Customer>().Property(p => p.Email).HasMaxLength(100);
modelBuilder.Entity<Customer>().Property(p => p.Phonenumber).HasMaxLength(20);
modelBuilder.Entity<CompanyPerson>().Property(p => p.Email).HasMaxLength(100);
modelBuilder.Entity<CompanyPerson>().Property(p => p.Phonenumber).HasMaxLength(20);
modelBuilder.Entity<Entities.Action>().Property(p => p.Name).HasMaxLength(20);
modelBuilder.Entity<Entities.Action>().Property(p => p.Value).HasMaxLength(100);
modelBuilder.Entity<Entities.InformationItem>().Property(p => p.Value).HasMaxLength(100);
base.OnModelCreating(modelBuilder);
}
示例13: SetupModel
internal static void SetupModel(DbModelBuilder builder)
{
builder.Entity<Employee>();
builder.Entity<Building>()
.HasOptional(b => b.PrincipalMailRoom)
.WithMany()
.HasForeignKey(b => b.PrincipalMailRoomId);
builder.ComplexType<Address>();
builder.ComplexType<SiteInfo>();
builder.Entity<MailRoom>()
.HasRequired(m => m.Building)
.WithMany(b => b.MailRooms)
.HasForeignKey(m => m.BuildingId);
builder.Entity<Office>().HasKey(
o => new
{
o.Number,
o.BuildingId
});
builder.Ignore<UnMappedOffice>();
builder.Entity<BuildingDetail>()
.HasKey(d => d.BuildingId)
.HasRequired(d => d.Building).WithOptional();
builder.Entity<Building>().Ignore(b => b.NotInModel);
builder.ComplexType<Address>().Ignore(a => a.County);
}
示例14: OnModelCreating
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.Conventions
.Remove<NavigationPropertyNameForeignKeyDiscoveryConvention>();
modelBuilder.Conventions.Remove<StoreGeneratedIdentityKeyConvention>();
modelBuilder.Properties<DateTime>()
.Configure(c => c.HasColumnType("datetime"));
modelBuilder.Properties<string>()
.Configure(c => c.HasColumnType("varchar"));
modelBuilder.Properties<string>()
.Configure(c => c.HasMaxLength(500));
modelBuilder.Properties()
.Where(x => x.Name == "Id")
.Configure(c => c.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity));
modelBuilder.Properties<DateTime>()
.Where(x => x.Name == "FechaRegistro")
.Configure(c => c.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed));
modelBuilder.HasDefaultSchema("dbo");
modelBuilder.Ignore<ICollection>();
modelBuilder.Entity<Organizacion>().HasKey(x => new {x.EmpresaId, x.PaisId});
}
示例15: OnModelCreating
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
//TODO: Ignore base classes
//modelBuilder.Entity<Permission>().ToTable("AbpPermissions");
//modelBuilder.Entity<UserRole>().ToTable("AbpUserRoles");
//modelBuilder.Entity<Setting>().ToTable("AbpSettings");
//modelBuilder.Entity<AbpRole>().ToTable("AbpRoles");
//modelBuilder.Entity<AbpTenant>().ToTable("AbpTenants");
//modelBuilder.Entity<UserLogin>().ToTable("AbpUserLogins");
//modelBuilder.Entity<UserRole>().ToTable("AbpUserRoles");
//modelBuilder.Entity<AbpRole>().HasMany(r => r.Permissions).WithRequired().HasForeignKey(p => p.RoleId);
//modelBuilder.Entity<UserRole>().HasRequired(ur => ur.Role);
//modelBuilder.Entity<UserRole>().HasRequired(ur => ur.User);
//modelBuilder.Entity<AbpUser>().ToTable("AbpUsers");
modelBuilder.Ignore<AbpUser>();
modelBuilder.Entity<TaskeverUser>().ToTable("AbpUsers");
modelBuilder.Entity<Activity>().ToTable("TeActivities")
.Map<CreateTaskActivity>(m => m.Requires("ActivityType").HasValue(1))
.Map<CompleteTaskActivity>(m => m.Requires("ActivityType").HasValue(2));
//modelBuilder.Entity<CompleteTaskActivity>()
modelBuilder.Entity<Friendship>().ToTable("TeFriendships");
modelBuilder.Entity<Task>().ToTable("TeTasks");
modelBuilder.Entity<UserFollowedActivity>().ToTable("TeUserFollowedActivities");
}