Index: branches/OaaS/HeuristicLab 3.3 Services.sln
===================================================================
--- branches/OaaS/HeuristicLab 3.3 Services.sln	(revision 9578)
+++ branches/OaaS/HeuristicLab 3.3 Services.sln	(revision 9579)
@@ -377,4 +377,5 @@
 		{5DC3E4F1-E21B-4C18-8921-88058E86FB07}.Release|x86.ActiveCfg = Release|Any CPU
 		{07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Debug|Any CPU.ActiveCfg = Debug|x86
+		{07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Debug|Any CPU.Build.0 = Debug|x86
 		{07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
 		{07D84A1D-56B7-4A8A-87EF-303A8518D48C}.Debug|Mixed Platforms.Build.0 = Debug|x86
Index: branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/App.config
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/App.config	(revision 9578)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/App.config	(revision 9579)
@@ -1,6 +1,13 @@
 ﻿<?xml version="1.0" encoding="utf-8"?>
 <configuration>
+  <configSections>
+    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
+    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+  </configSections>
   <connectionStrings>
-    <add name="BillingContext" connectionString="ADJUST_ME" providerName="System.Data.SqlClient"/>
+    <add name="BillingContext" connectionString="ADJUST_ME" providerName="System.Data.SqlClient" />
   </connectionStrings>
+  <entityFramework>
+    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
+  </entityFramework>
 </configuration>
Index: branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/HeuristicLab.Services.Optimization.Billing.Test.csproj
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/HeuristicLab.Services.Optimization.Billing.Test.csproj	(revision 9578)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/HeuristicLab.Services.Optimization.Billing.Test.csproj	(revision 9579)
@@ -35,6 +35,11 @@
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+      <HintPath>..\packages\EntityFramework.5.0.0\lib\net40\EntityFramework.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
+    <Reference Include="System.ComponentModel.DataAnnotations" />
     <Reference Include="System.Core" />
+    <Reference Include="System.Data.Entity" />
     <Reference Include="System.Xml.Linq" />
     <Reference Include="System.Data.DataSetExtensions" />
@@ -55,4 +60,5 @@
   <ItemGroup>
     <None Include="App.config" />
+    <None Include="packages.config" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Index: branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/Program.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/Program.cs	(revision 9578)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/Program.cs	(revision 9579)
@@ -1,11 +1,19 @@
 ﻿using System;
 using HeuristicLab.Services.Optimization.Billing.DataAccess;
+using HeuristicLab.Services.Optimization.Billing.Model;
 
 namespace HeuristicLab.Services.Optimization.Billing.Test {
   class Program {
     static void Main(string[] args) {
+      using (var context = new BillingContext()) {
+        System.Data.Entity.Database.SetInitializer(new HeuristicLab.Services.Optimization.Billing.DataAccess.BillingContext.BillingContextInitiliazer());
+      }
+
       //BillingService srv = new BillingService();
       BillingDao dao = new BillingDao();
-      dao.FindAllProducts();
+      var products = dao.FindAllProducts();
+      foreach (Product p in products) {
+        Console.WriteLine(string.Format("{0}: {1}", p.ProductId, p.Name));
+      }
 
       Console.WriteLine("Press any key to exit...");
Index: branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/packages.config
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/packages.config	(revision 9579)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/packages.config	(revision 9579)
@@ -0,0 +1,4 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="EntityFramework" version="5.0.0" targetFramework="net40-Client" />
+</packages>
Index: branches/OaaS/HeuristicLab.Services.Optimization.Billing/DataAccess/BillingContext.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Billing/DataAccess/BillingContext.cs	(revision 9578)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Billing/DataAccess/BillingContext.cs	(revision 9579)
@@ -13,4 +13,5 @@
     public DbSet<Invoice> Invoices { get; set; }
     public DbSet<InvoiceLine> InvoiceLines { get; set; }
+    public DbSet<UsageRecord> UsageRecords { get; set; }
 
     // enum PaymentMethod
@@ -33,5 +34,4 @@
       modelBuilder.Configurations.Add(new InvoiceLineConfiguration());
       modelBuilder.Configurations.Add(new UsageRecordConfiguration());
-      modelBuilder.Configurations.Add(new UsageRecordLineConfiguration());
 
       modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
@@ -45,5 +45,4 @@
       internal OrderConfiguration() {
         this.HasRequired(o => o.User).WithMany().HasForeignKey(o => o.UserId);
-        //this.HasMany<Invoice>(o => o.Invoices).WithRequired().HasForeignKey(i => i.OrderId);
         // TODO: OrderState?
       }
@@ -52,5 +51,5 @@
     private class OrderLineConfiguration : EntityTypeConfiguration<OrderLine> {
       internal OrderLineConfiguration() {
-        this.HasRequired(ol => ol.Order).WithMany().HasForeignKey(ol => ol.OrderId);
+        this.HasRequired(ol => ol.Order).WithMany(o => o.OrderLines).HasForeignKey(ol => ol.OrderId).WillCascadeOnDelete(true);
         this.HasRequired(ol => ol.Product).WithMany().HasForeignKey(ol => ol.ProductId);
       }
@@ -60,5 +59,5 @@
       internal InvoiceConfiguration() {
         this.HasRequired(i => i.User).WithMany().HasForeignKey(i => i.UserId);
-        this.HasRequired(i => i.Order).WithMany().HasForeignKey(i => i.OrderId);
+        this.HasRequired(i => i.Order).WithMany(o => o.Invoices).HasForeignKey(i => i.OrderId);
       }
     }
@@ -66,5 +65,5 @@
     private class InvoiceLineConfiguration : EntityTypeConfiguration<InvoiceLine> {
       internal InvoiceLineConfiguration() {
-        this.HasRequired(il => il.Invoice).WithMany().HasForeignKey(il => il.InvoiceId);
+        this.HasRequired(il => il.Invoice).WithMany(i => i.InvoiceLines).HasForeignKey(il => il.InvoiceId).WillCascadeOnDelete(true);
         this.HasRequired(il => il.Product).WithMany().HasForeignKey(il => il.ProductId);
       }
@@ -74,10 +73,5 @@
       internal UsageRecordConfiguration() {
         this.HasRequired(ur => ur.User).WithMany().HasForeignKey(ur => ur.UserId);
-      }
-    }
-
-    private class UsageRecordLineConfiguration : EntityTypeConfiguration<UsageRecordLine> {
-      internal UsageRecordLineConfiguration() {
-        this.HasRequired(url => url.UsageRecord).WithMany().HasForeignKey(url => url.UsageRecordId);
+        this.HasRequired(ur => ur.Product).WithMany().HasForeignKey(ur => ur.ProductId);
       }
     }
Index: branches/OaaS/HeuristicLab.Services.Optimization.Billing/Model/Model.cs
===================================================================
--- branches/OaaS/HeuristicLab.Services.Optimization.Billing/Model/Model.cs	(revision 9578)
+++ branches/OaaS/HeuristicLab.Services.Optimization.Billing/Model/Model.cs	(revision 9579)
@@ -81,4 +81,5 @@
     public virtual User User { get; set; }
     public virtual Order Order { get; set; }
+    public virtual IList<InvoiceLine> InvoiceLines { get; set; }
   }
 
@@ -97,16 +98,12 @@
     public long UsageRecordId { get; set; }
     public long UserId { get; set; }
+    public long ProductId { get; set; }
+    public DateTime Begin { get; set; }
+    public DateTime End { get; set; }
+    public int ServiceIdentifier { get; set; }
+    public int ResourceIdentifier { get; set; }
 
     public virtual User User { get; set; }
-    public virtual IList<UsageRecordLine> UsageRecordLines { get; set; }
-  }
-
-  public class UsageRecordLine {
-    public long UsageRecordLineId { get; set; }
-    public long UsageRecordId { get; set; }
-    public DateTime Begin { get; set; }
-    public DateTime End { get; set; }
-
-    public virtual UsageRecord UsageRecord { get; set; }
+    public virtual Product Product { get; set; }
   }
 }
