- Timestamp:
- 06/04/13 14:57:46 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS/HeuristicLab.Services.Optimization.Billing/DataAccess/BillingContext.cs
r9577 r9579 13 13 public DbSet<Invoice> Invoices { get; set; } 14 14 public DbSet<InvoiceLine> InvoiceLines { get; set; } 15 public DbSet<UsageRecord> UsageRecords { get; set; } 15 16 16 17 // enum PaymentMethod … … 33 34 modelBuilder.Configurations.Add(new InvoiceLineConfiguration()); 34 35 modelBuilder.Configurations.Add(new UsageRecordConfiguration()); 35 modelBuilder.Configurations.Add(new UsageRecordLineConfiguration());36 36 37 37 modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>(); … … 45 45 internal OrderConfiguration() { 46 46 this.HasRequired(o => o.User).WithMany().HasForeignKey(o => o.UserId); 47 //this.HasMany<Invoice>(o => o.Invoices).WithRequired().HasForeignKey(i => i.OrderId);48 47 // TODO: OrderState? 49 48 } … … 52 51 private class OrderLineConfiguration : EntityTypeConfiguration<OrderLine> { 53 52 internal OrderLineConfiguration() { 54 this.HasRequired(ol => ol.Order).WithMany( ).HasForeignKey(ol => ol.OrderId);53 this.HasRequired(ol => ol.Order).WithMany(o => o.OrderLines).HasForeignKey(ol => ol.OrderId).WillCascadeOnDelete(true); 55 54 this.HasRequired(ol => ol.Product).WithMany().HasForeignKey(ol => ol.ProductId); 56 55 } … … 60 59 internal InvoiceConfiguration() { 61 60 this.HasRequired(i => i.User).WithMany().HasForeignKey(i => i.UserId); 62 this.HasRequired(i => i.Order).WithMany( ).HasForeignKey(i => i.OrderId);61 this.HasRequired(i => i.Order).WithMany(o => o.Invoices).HasForeignKey(i => i.OrderId); 63 62 } 64 63 } … … 66 65 private class InvoiceLineConfiguration : EntityTypeConfiguration<InvoiceLine> { 67 66 internal InvoiceLineConfiguration() { 68 this.HasRequired(il => il.Invoice).WithMany( ).HasForeignKey(il => il.InvoiceId);67 this.HasRequired(il => il.Invoice).WithMany(i => i.InvoiceLines).HasForeignKey(il => il.InvoiceId).WillCascadeOnDelete(true); 69 68 this.HasRequired(il => il.Product).WithMany().HasForeignKey(il => il.ProductId); 70 69 } … … 74 73 internal UsageRecordConfiguration() { 75 74 this.HasRequired(ur => ur.User).WithMany().HasForeignKey(ur => ur.UserId); 76 } 77 } 78 79 private class UsageRecordLineConfiguration : EntityTypeConfiguration<UsageRecordLine> { 80 internal UsageRecordLineConfiguration() { 81 this.HasRequired(url => url.UsageRecord).WithMany().HasForeignKey(url => url.UsageRecordId); 75 this.HasRequired(ur => ur.Product).WithMany().HasForeignKey(ur => ur.ProductId); 82 76 } 83 77 }
Note: See TracChangeset
for help on using the changeset viewer.