public ItSystemMap() { // Properties // BUG there's an issue with indexing http://stackoverflow.com/questions/26055140/ef-migrations-drops-index-when-adding-compsite-index this.Property(x => x.OrganizationId) .HasUniqueIndexAnnotation("UX_NamePerOrg", 0); this.Property(x => x.Name) .HasMaxLength(ItSystem.MaxNameLength) // http://stackoverflow.com/questions/1827063/mysql-error-key-specification-without-a-key-length .IsRequired() .HasUniqueIndexAnnotation("UX_NamePerOrg", 1); // Table & Column Mappings this.ToTable("ItSystem"); // Relationships this.HasOptional(t => t.Parent) .WithMany(d => d.Children) .HasForeignKey(t => t.ParentId) .WillCascadeOnDelete(false); this.HasRequired(t => t.Organization) .WithMany(d => d.ItSystems) .HasForeignKey(t => t.OrganizationId) .WillCascadeOnDelete(false); this.HasOptional(t => t.BelongsTo) .WithMany(d => d.BelongingSystems) .HasForeignKey(t => t.BelongsToId); this.HasOptional(t => t.BusinessType) .WithMany(t => t.References) .HasForeignKey(t => t.BusinessTypeId); this.HasMany(t => t.ItInterfaceExhibits) .WithRequired(t => t.ItSystem) .HasForeignKey(d => d.ItSystemId); HasOptional(t => t.Reference); HasMany(t => t.ExternalReferences) .WithOptional(d => d.ItSystem) .HasForeignKey(d => d.ItSystem_Id) //No cascading delete in order to avoid causing cycles or multiple cascade paths .WillCascadeOnDelete(false); Property(x => x.Uuid) .IsRequired() .HasUniqueIndexAnnotation("UX_System_Uuuid", 0); TypeMapping.AddIndexOnAccessModifier <ItSystemMap, ItSystem>(this); }
public ItInterfaceMap() { // Properties this.Property(x => x.Version).HasMaxLength(20); // BUG there's an issue with indexing http://stackoverflow.com/questions/26055140/ef-migrations-drops-index-when-adding-compsite-index this.Property(x => x.OrganizationId) .HasUniqueIndexAnnotation("UX_NamePerOrg", 0); this.Property(x => x.Name) .HasMaxLength(ItInterface.MaxNameLength) .IsRequired() .HasUniqueIndexAnnotation("UX_NamePerOrg", 1); this.Property(x => x.ItInterfaceId) .HasMaxLength(100) // this should really be optional but because // MySql doesn't follow the SQL standard // when it comes to unique indexs with nulls in them - we can't... // http://bugs.mysql.com/bug.php?id=8173 // So instead we set it to an empty string :´( // TODO we're no longer using MySql so we can fix this .IsRequired() .HasUniqueIndexAnnotation("UX_NamePerOrg", 2); // Table & Column Mappings this.ToTable("ItInterface"); // Relationships // Udkommenteret ifm. OS2KITOS-663 //this.HasMany(t => t.CanBeUsedBy) // .WithRequired(t => t.ItInterface) // .HasForeignKey(d => d.ItInterfaceId); this.HasOptional(t => t.Interface) .WithMany(d => d.References) .HasForeignKey(t => t.InterfaceId); this.HasRequired(t => t.Organization) .WithMany(d => d.ItInterfaces) .HasForeignKey(t => t.OrganizationId) .WillCascadeOnDelete(false); TypeMapping.AddIndexOnAccessModifier <ItInterfaceMap, ItInterface>(this); }
public OrganizationMap() { // Properties Property(x => x.Name) .HasMaxLength(Organization.MaxNameLength) // http://stackoverflow.com/questions/1827063/mysql-error-key-specification-without-a-key-length .HasColumnAnnotation(IndexAnnotation.AnnotationName, new IndexAnnotation(new IndexAttribute())); Property(t => t.Cvr) .HasMaxLength(10) .IsOptional() .HasColumnAnnotation(IndexAnnotation.AnnotationName, new IndexAnnotation(new IndexAttribute())); // Table & Column Mappings ToTable("Organization"); // Relationships HasOptional(t => t.Config) .WithRequired(t => t.Organization) .WillCascadeOnDelete(true); HasRequired(t => t.Type) .WithMany(t => t.Organizations) .HasForeignKey(t => t.TypeId) .WillCascadeOnDelete(false); HasMany(m => m.Reports) .WithRequired(m => m.Organization) .HasForeignKey(m => m.OrganizationId) .WillCascadeOnDelete(false); HasOptional(o => o.ContactPerson) .WithOptionalDependent(c => c.Organization) .WillCascadeOnDelete(true); TypeMapping.AddIndexOnAccessModifier <OrganizationMap, Organization>(this); Property(x => x.Uuid) .IsRequired() .HasUniqueIndexAnnotation("UX_Organization_UUID", 0); }
public EconomyStreamMap() { // Properties // Table & Column Mappings this.ToTable("EconomyStream"); // Relationships this.HasOptional(t => t.ExternPaymentFor) .WithMany(d => d.ExternEconomyStreams) .HasForeignKey(t => t.ExternPaymentForId) .WillCascadeOnDelete(false); this.HasOptional(t => t.InternPaymentFor) .WithMany(d => d.InternEconomyStreams) .HasForeignKey(t => t.InternPaymentForId) .WillCascadeOnDelete(false); this.HasOptional(t => t.OrganizationUnit) .WithMany(d => d.EconomyStreams) .HasForeignKey(t => t.OrganizationUnitId) .WillCascadeOnDelete(false); TypeMapping.AddIndexOnAccessModifier <EconomyStreamMap, EconomyStream>(this); }
public ReportMap() { TypeMapping.AddIndexOnAccessModifier <ReportMap, Report>(this); }
public ItProjectMap() { // Properties this.Property(x => x.Name) .HasMaxLength(ItProjectConstraints.MaxNameLength) .IsRequired() .HasIndexAnnotation("Project_Index_Name", 0); // Table & Column Mappings ToTable("ItProject"); HasRequired(t => t.Organization) .WithMany(d => d.ItProjects) .HasForeignKey(t => t.OrganizationId) .WillCascadeOnDelete(false); HasOptional(t => t.ItProjectType) .WithMany(d => d.References) .HasForeignKey(t => t.ItProjectTypeId); HasOptional(t => t.Parent) .WithMany(d => d.Children) .HasForeignKey(t => t.ParentId) .WillCascadeOnDelete(false); HasMany(t => t.UsedByOrgUnits) .WithRequired(t => t.ItProject) .HasForeignKey(d => d.ItProjectId); HasMany(t => t.EconomyYears) .WithRequired(d => d.ItProject) .HasForeignKey(d => d.ItProjectId) .WillCascadeOnDelete(true); HasMany(t => t.ItSystemUsages) .WithMany(t => t.ItProjects); HasMany(t => t.TaskRefs) .WithMany(t => t.ItProjects); HasOptional(t => t.JointMunicipalProject) .WithMany(t => t.JointMunicipalProjects) .HasForeignKey(d => d.JointMunicipalProjectId) .WillCascadeOnDelete(false); HasOptional(t => t.CommonPublicProject) .WithMany(t => t.CommonPublicProjects) .HasForeignKey(d => d.CommonPublicProjectId) .WillCascadeOnDelete(false); HasMany(t => t.Risks) .WithRequired(d => d.ItProject) .HasForeignKey(d => d.ItProjectId) .WillCascadeOnDelete(true); HasOptional(t => t.Reference); HasMany(t => t.ExternalReferences) .WithOptional(d => d.ItProject) .HasForeignKey(d => d.ItProject_Id) .WillCascadeOnDelete(true); HasOptional(t => t.ResponsibleUsage) .WithOptionalPrincipal(t => t.ResponsibleItProject); HasOptional(t => t.Original) .WithMany(t => t.Clones) .HasForeignKey(d => d.OriginalId) .WillCascadeOnDelete(false); HasMany(t => t.Stakeholders) .WithRequired(d => d.ItProject) .HasForeignKey(d => d.ItProjectId) .WillCascadeOnDelete(true); HasMany(e => e.ItProjectStatusUpdates) .WithOptional(e => e.AssociatedItProject) .HasForeignKey(e => e.AssociatedItProjectId) .WillCascadeOnDelete(true); TypeMapping.AddIndexOnAccessModifier <ItProjectMap, ItProject>(this); }