Index: /branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStore.cs
===================================================================
--- /branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStore.cs	(revision 2765)
+++ /branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStore.cs	(revision 2766)
@@ -55,7 +55,5 @@
 
     public byte[] PluginFile(PluginDescription pluginDescription) {
-      return (from file in ctx.PluginPackages
-              where file.PluginId == pluginDescription.Id
-              select file.Data.ToArray()).Single();
+      return GetExistingPlugin(pluginDescription.Name, pluginDescription.Version).PluginPackage.Data.ToArray();
     }
 
@@ -63,6 +61,12 @@
       try {
         using (var transaction = new TransactionScope()) {
-          InsertOrUpdatePlugin(pluginDescription);
-          InsertOrUpdatePluginPackage(pluginDescription, pluginPackage);
+          Plugin pluginEntity = InsertOrUpdatePlugin(pluginDescription);
+          if (pluginEntity.PluginPackage == null) {
+            // insert
+            pluginEntity.PluginPackage = MakePluginPackage(pluginDescription, pluginPackage);
+          } else {
+            // update
+            pluginEntity.PluginPackage.Data = pluginPackage;
+          }
           ctx.SubmitChanges();
           transaction.Complete();
@@ -72,96 +76,99 @@
         throw new ArgumentException("Something went wrong while trying to persist plugin", ex);
       }
+      catch (InvalidOperationException ex) {
+        throw new ArgumentException("Something went wrong while trying to persist plugin", ex);
+      }
     }
 
     public void Persist(ProductDescription product) {
-      using (var transaction = new TransactionScope()) {
-        InsertOrUpdateProduct(product);
-        foreach (var plugin in product.Plugins) {
-          InsertOrUpdatePlugin(plugin);
+      try {
+        using (var transaction = new TransactionScope()) {
+          InsertOrUpdateProduct(product);
+          foreach (var plugin in product.Plugins) {
+            InsertOrUpdatePlugin(plugin);
+          }
+          ctx.SubmitChanges();
+          transaction.Complete();
         }
-        ctx.SubmitChanges();
-        transaction.Complete();
       }
-    }
-
-    private void InsertOrUpdatePluginPackage(PluginDescription pluginDescription, byte[] pluginPackage) {
-      var existing = from p in ctx.PluginPackages
-                     where p.PluginId == pluginDescription.Id
-                     select p;
-
-      if (existing.Count() == 0) {
-        ctx.PluginPackages.InsertOnSubmit(MakePluginPackage(pluginDescription, pluginPackage));
-      } else {
-        var exisingPackage = existing.Single();
-        exisingPackage.Data = pluginPackage;
+      catch (SqlException ex) {
+        throw new ArgumentException("Something went wrong while trying to persist product", ex);
+      }
+      catch (InvalidOperationException ex) {
+        throw new ArgumentException("Something went wrong while trying to persist product", ex);
       }
     }
 
     private void InsertOrUpdateProduct(ProductDescription product) {
-      var existing = from p in ctx.Products
-                     where p.Id == product.Id
-                     select p;
-      if (existing.Count() == 0) {
-        var newEntity = MakeProductFromDescription(product);
-        ctx.Products.InsertOnSubmit(newEntity);
-        // submit and write back db generated key
+      var productEntity = (from p in ctx.Products
+                           where p.Name == product.Name
+                           where p.Version == product.Version.ToString()
+                           select p).FirstOrDefault() ?? MakeProductFromDescription(product);
+
+      if (productEntity.Id <= 0) {
+        ctx.Products.InsertOnSubmit(productEntity);
         ctx.SubmitChanges();
-        product.Id = newEntity.Id;
-      } else {
-        var existingProduct = existing.Single();
-        existingProduct.Name = product.Name;
-        existingProduct.Version = product.Version.ToString();
       }
+
+      product.Id = productEntity.Id;
+
+      DeleteOldPlugins(productEntity);
+
       foreach (var plugin in product.Plugins) {
-        InsertOrUpdateProductPlugin(plugin, product);
-        InsertOrUpdatePlugin(plugin);
+        var existingPlugin = GetExistingPlugin(plugin.Name, plugin.Version);
+        ProductPlugin prodPlugin = new ProductPlugin();
+        prodPlugin.PluginId = existingPlugin.Id;
+        prodPlugin.ProductId = product.Id;
+        ctx.ProductPlugins.InsertOnSubmit(prodPlugin);
       }
     }
 
-    private void InsertOrUpdateProductPlugin(PluginDescription plugin, ProductDescription product) {
-      var existing = from pair in ctx.ProductPlugins
-                     where pair.PluginId == plugin.Id
-                     where pair.ProductId == product.Id
-                     select pair;
-      if (existing.Count() != 0) {
-        var newEntity = new ProductPlugin();
-        newEntity.PluginId = plugin.Id;
-        newEntity.ProductId = product.Id;
-        ctx.ProductPlugins.InsertOnSubmit(newEntity);
-      }
+    private void DeleteOldPlugins(Product productEntity) {
+      var oldPlugins = (from p in ctx.ProductPlugins
+                        where p.ProductId == productEntity.Id
+                        select p).ToList();
+      ctx.ProductPlugins.DeleteAllOnSubmit(oldPlugins);
+      ctx.SubmitChanges();
     }
 
-    private void InsertOrUpdatePlugin(PluginDescription plugin) {
-      var existing = from p in ctx.Plugins
-                     where p.Name == plugin.Name
-                     where p.Version == plugin.Version.ToString()
-                     select p;
-      if (existing.Count() == 0) {
-        var newEntity = MakePluginFromDescription(plugin);
-        ctx.Plugins.InsertOnSubmit(newEntity);
-        // submit and write back db generated key
+    private Plugin InsertOrUpdatePlugin(PluginDescription pluginDescription) {
+      var pluginEntity = (from p in ctx.Plugins
+                          where p.Name == pluginDescription.Name
+                          where p.Version == pluginDescription.Version.ToString()
+                          select p).FirstOrDefault() ?? MakePluginFromDescription(pluginDescription);
+
+      if (pluginEntity.Id <= 0) {
+        ctx.Plugins.InsertOnSubmit(pluginEntity);
         ctx.SubmitChanges();
-        plugin.Id = newEntity.Id;
-      } else {
-        var existingPlugin = existing.Single();
-        plugin.Id = existingPlugin.Id;
       }
-      foreach (var dependency in plugin.Dependencies) {
-        InsertOrUpdateDependency(plugin, dependency);
-        InsertOrUpdatePlugin(dependency);
+      pluginDescription.Id = pluginEntity.Id;
+
+      DeleteOldDependencies(pluginEntity);
+
+      foreach (var dependency in pluginDescription.Dependencies) {
+        var dependencyEntity = GetExistingPlugin(dependency.Name, dependency.Version);
+        Dependency d = new Dependency();
+        d.PluginId = pluginDescription.Id;
+        d.DependencyId = dependencyEntity.Id;
+        ctx.Dependencies.InsertOnSubmit(d);
       }
+      return pluginEntity;
+
     }
 
-    private void InsertOrUpdateDependency(PluginDescription plugin, PluginDescription dependency) {
-      var existing = from pair in ctx.Dependencies
-                     where pair.DependencyId == dependency.Id
-                     where pair.PluginId == plugin.Id
-                     select pair;
-      if (existing.Count() == 0) {
-        var newEntity = new Dependency();
-        newEntity.PluginId = plugin.Id;
-        newEntity.DependencyId = dependency.Id;
-        ctx.Dependencies.InsertOnSubmit(newEntity);
-      }
+    private void DeleteOldDependencies(Plugin pluginEntity) {
+      var oldDependencies = (from dep in ctx.Dependencies
+                             where dep.PluginId == pluginEntity.Id
+                             select dep).ToList();
+
+      ctx.Dependencies.DeleteAllOnSubmit(oldDependencies);
+      ctx.SubmitChanges();
+    }
+
+    private Plugin GetExistingPlugin(string name, Version version) {
+      return (from p in ctx.Plugins
+              where p.Name == name
+              where p.Version == version.ToString()
+              select p).Single();
     }
 
Index: /branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStoreClasses.dbml
===================================================================
--- /branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStoreClasses.dbml	(revision 2765)
+++ /branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStoreClasses.dbml	(revision 2766)
@@ -6,14 +6,10 @@
       <Column Name="PluginId" Type="System.Int64" DbType="BigInt NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
       <Column Name="DependencyId" Type="System.Int64" DbType="BigInt NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
-      <Association Name="Plugin_Dependency" Member="Plugin" ThisKey="DependencyId" OtherKey="Id" Type="Plugin" IsForeignKey="true" />
-      <Association Name="Plugin_Dependency1" Member="Plugin1" ThisKey="PluginId" OtherKey="Id" Type="Plugin" IsForeignKey="true" />
     </Type>
   </Table>
   <Table Name="dbo.ProductPlugin" Member="ProductPlugins">
     <Type Name="ProductPlugin">
-      <Column Name="ProductId" Type="System.Int64" DbType="BigInt NOT NULL" CanBeNull="false" />
-      <Column Name="PluginId" Type="System.Int64" DbType="BigInt NOT NULL" CanBeNull="false" />
-      <Association Name="Plugin_ProductPlugin" Member="Plugin" ThisKey="PluginId" OtherKey="Id" Type="Plugin" IsForeignKey="true" />
-      <Association Name="Product_ProductPlugin" Member="Product" ThisKey="ProductId" OtherKey="Id" Type="Product" IsForeignKey="true" />
+      <Column Name="ProductId" Type="System.Int64" DbType="BigInt NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
+      <Column Name="PluginId" Type="System.Int64" DbType="BigInt NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
     </Type>
   </Table>
@@ -23,7 +19,4 @@
       <Column Name="Name" Type="System.String" DbType="NVarChar(300) NOT NULL" CanBeNull="false" />
       <Column Name="Version" Type="System.String" DbType="NVarChar(50) NOT NULL" CanBeNull="false" />
-      <Association Name="Plugin_Dependency" Member="Dependencies" ThisKey="Id" OtherKey="DependencyId" Type="Dependency" />
-      <Association Name="Plugin_Dependency1" Member="Dependencies1" ThisKey="Id" OtherKey="PluginId" Type="Dependency" />
-      <Association Name="Plugin_ProductPlugin" Member="ProductPlugins" ThisKey="Id" OtherKey="PluginId" Type="ProductPlugin" />
       <Association Name="Plugin_PluginPackage" Member="PluginPackage" ThisKey="Id" OtherKey="PluginId" Type="PluginPackage" Cardinality="One" />
     </Type>
@@ -39,8 +32,7 @@
   <Table Name="dbo.Product" Member="Products">
     <Type Name="Product">
-      <Column Name="Id" Type="System.Int64" DbType="BigInt NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
+      <Column Name="Id" Type="System.Int64" DbType="BigInt NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
       <Column Name="Name" Type="System.String" DbType="NVarChar(300) NOT NULL" CanBeNull="false" />
       <Column Name="Version" Type="System.String" DbType="NVarChar(50) NOT NULL" CanBeNull="false" />
-      <Association Name="Product_ProductPlugin" Member="ProductPlugins" ThisKey="Id" OtherKey="ProductId" Type="ProductPlugin" />
     </Type>
   </Table>
Index: /branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStoreClasses.dbml.layout
===================================================================
--- /branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStoreClasses.dbml.layout	(revision 2765)
+++ /branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStoreClasses.dbml.layout	(revision 2766)
@@ -3,67 +3,39 @@
   <DataContextMoniker Name="/PluginStoreClassesDataContext" />
   <nestedChildShapes>
-    <classShape Id="b23b573a-6180-4641-ba9f-1bd9637deeff" absoluteBounds="3.5, 2.625, 2, 1.1939925130208335">
+    <classShape Id="8eaeae9c-08a1-4be4-b58a-e3bf24f1961b" absoluteBounds="3.5, 2.625, 2, 1.1939925130208335">
       <DataClassMoniker Name="/PluginStoreClassesDataContext/Dependency" />
       <nestedChildShapes>
-        <elementListCompartment Id="0c1faa24-a5ab-4093-b697-127ff9dec797" absoluteBounds="3.515, 3.085, 1.9700000000000002, 0.63399251302083326" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
+        <elementListCompartment Id="c05168fe-dac9-499f-bf93-2ba4d92d3a81" absoluteBounds="3.515, 3.085, 1.9700000000000002, 0.63399251302083326" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
       </nestedChildShapes>
     </classShape>
-    <classShape Id="89bb29fc-6da5-4fb3-9df3-a33da1cc99f8" absoluteBounds="3.5, 0.75, 2, 1.1939925130208335">
+    <classShape Id="5f1b7d3a-0078-4834-a616-5cf8b1894803" absoluteBounds="3.5, 0.75, 2, 1.1939925130208335">
       <DataClassMoniker Name="/PluginStoreClassesDataContext/ProductPlugin" />
       <nestedChildShapes>
-        <elementListCompartment Id="6eb3746b-0fec-4c95-8d53-03316bf2003a" absoluteBounds="3.515, 1.21, 1.9700000000000002, 0.63399251302083326" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
+        <elementListCompartment Id="66444473-2d73-4b22-9e6b-c440e2654f3f" absoluteBounds="3.515, 1.21, 1.9700000000000002, 0.63399251302083326" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
       </nestedChildShapes>
     </classShape>
-    <classShape Id="c8a72752-dc21-43bd-8c14-169c06461993" absoluteBounds="0.75, 3.625, 2, 1.3862939453125">
+    <classShape Id="37f2647d-7364-4f13-a869-2c8ebbc23260" absoluteBounds="0.75, 3.625, 2, 1.3862939453125">
       <DataClassMoniker Name="/PluginStoreClassesDataContext/Plugin" />
       <nestedChildShapes>
-        <elementListCompartment Id="f85c30fe-b967-4cf5-ba0b-643fc01e8481" absoluteBounds="0.765, 4.085, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
+        <elementListCompartment Id="70f53f38-ca24-4ef6-8b0a-f3be78ad76c7" absoluteBounds="0.765, 4.085, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
       </nestedChildShapes>
     </classShape>
-    <classShape Id="3b48239e-4f4a-46d0-9962-fdc1173ba7bb" absoluteBounds="3.5, 6.625, 2, 1.3862939453125005">
+    <classShape Id="6d0553e8-405a-4315-bc54-7af25f2a415d" absoluteBounds="3.5, 6.625, 2, 1.3862939453125005">
       <DataClassMoniker Name="/PluginStoreClassesDataContext/PluginPackage" />
       <nestedChildShapes>
-        <elementListCompartment Id="e3a729ff-4cdf-44f7-b4da-0b4adc2bf9db" absoluteBounds="3.515, 7.085, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
+        <elementListCompartment Id="4bc7352f-2d30-4f49-897e-c741d0a60123" absoluteBounds="3.515, 7.085, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
       </nestedChildShapes>
     </classShape>
-    <classShape Id="2c5978b1-ebd4-4998-88f6-6f519a81c5b9" absoluteBounds="0.75, 1.5, 2, 1.3862939453125003">
+    <classShape Id="c36a4ae4-62d6-4891-9389-afdef8241ad1" absoluteBounds="0.75, 1.5, 2, 1.3862939453125003">
       <DataClassMoniker Name="/PluginStoreClassesDataContext/Product" />
       <nestedChildShapes>
-        <elementListCompartment Id="bfbec163-1dd5-435a-92e5-4d99b65b567f" absoluteBounds="0.765, 1.96, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
+        <elementListCompartment Id="ec5480b9-acee-4912-8ea6-a67dbb78a523" absoluteBounds="0.765, 1.96, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
       </nestedChildShapes>
     </classShape>
-    <associationConnector edgePoints="[(2.75 : 4.41514372916667); (3.88541416666667 : 4.41514372916667 : JumpStart); (4.05208083333333 : 4.41514372916667 : JumpEnd); (4.5 : 4.41514372916667); (4.5 : 3.81899251302083)]" fixedFrom="Algorithm" fixedTo="Algorithm">
-      <AssociationMoniker Name="/PluginStoreClassesDataContext/Plugin/Plugin_Dependency" />
-      <nodes>
-        <classShapeMoniker Id="c8a72752-dc21-43bd-8c14-169c06461993" />
-        <classShapeMoniker Id="b23b573a-6180-4641-ba9f-1bd9637deeff" />
-      </nodes>
-    </associationConnector>
-    <associationConnector edgePoints="[(2.75 : 4.74447133723958); (3.9687475 : 4.74447133723958); (3.9687475 : 3.81899251302083)]" fixedFrom="Algorithm" fixedTo="Algorithm">
-      <AssociationMoniker Name="/PluginStoreClassesDataContext/Plugin/Plugin_Dependency1" />
-      <nodes>
-        <classShapeMoniker Id="c8a72752-dc21-43bd-8c14-169c06461993" />
-        <classShapeMoniker Id="b23b573a-6180-4641-ba9f-1bd9637deeff" />
-      </nodes>
-    </associationConnector>
-    <associationConnector edgePoints="[(2.75 : 3.625); (3.125 : 3.25); (3.125 : 1.34699625651042); (3.5 : 1.34699625651042)]" fixedFrom="NotFixed" fixedTo="Algorithm">
-      <AssociationMoniker Name="/PluginStoreClassesDataContext/Plugin/Plugin_ProductPlugin" />
-      <nodes>
-        <classShapeMoniker Id="c8a72752-dc21-43bd-8c14-169c06461993" />
-        <classShapeMoniker Id="89bb29fc-6da5-4fb3-9df3-a33da1cc99f8" />
-      </nodes>
-    </associationConnector>
     <associationConnector edgePoints="[(1.75 : 5.0112939453125); (1.75 : 7.31814697265625); (3.5 : 7.31814697265625)]" fixedFrom="Algorithm" fixedTo="Algorithm">
       <AssociationMoniker Name="/PluginStoreClassesDataContext/Plugin/Plugin_PluginPackage" />
       <nodes>
-        <classShapeMoniker Id="c8a72752-dc21-43bd-8c14-169c06461993" />
-        <classShapeMoniker Id="3b48239e-4f4a-46d0-9962-fdc1173ba7bb" />
-      </nodes>
-    </associationConnector>
-    <associationConnector edgePoints="[(2.75 : 1.72199625651042); (3.04166666666667 : 1.72199625651042 : JumpStart); (3.20833333333333 : 1.72199625651042 : JumpEnd); (3.5 : 1.72199625651042)]" fixedFrom="Algorithm" fixedTo="Algorithm">
-      <AssociationMoniker Name="/PluginStoreClassesDataContext/Product/Product_ProductPlugin" />
-      <nodes>
-        <classShapeMoniker Id="2c5978b1-ebd4-4998-88f6-6f519a81c5b9" />
-        <classShapeMoniker Id="89bb29fc-6da5-4fb3-9df3-a33da1cc99f8" />
+        <classShapeMoniker Id="37f2647d-7364-4f13-a869-2c8ebbc23260" />
+        <classShapeMoniker Id="6d0553e8-405a-4315-bc54-7af25f2a415d" />
       </nodes>
     </associationConnector>
Index: /branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStoreClasses.designer.cs
===================================================================
--- /branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStoreClasses.designer.cs	(revision 2765)
+++ /branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStoreClasses.designer.cs	(revision 2766)
@@ -34,4 +34,7 @@
     partial void UpdateDependency(Dependency instance);
     partial void DeleteDependency(Dependency instance);
+    partial void InsertProductPlugin(ProductPlugin instance);
+    partial void UpdateProductPlugin(ProductPlugin instance);
+    partial void DeleteProductPlugin(ProductPlugin instance);
     partial void InsertPlugin(Plugin instance);
     partial void UpdatePlugin(Plugin instance);
@@ -126,8 +129,4 @@
 		private long _DependencyId;
 		
-		private EntityRef<Plugin> _Plugin;
-		
-		private EntityRef<Plugin> _Plugin1;
-		
     #region Extensibility Method Definitions
     partial void OnLoaded();
@@ -142,6 +141,4 @@
 		public Dependency()
 		{
-			this._Plugin = default(EntityRef<Plugin>);
-			this._Plugin1 = default(EntityRef<Plugin>);
 			OnCreated();
 		}
@@ -158,8 +155,4 @@
 				if ((this._PluginId != value))
 				{
-					if (this._Plugin1.HasLoadedOrAssignedValue)
-					{
-						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
-					}
 					this.OnPluginIdChanging(value);
 					this.SendPropertyChanging();
@@ -182,8 +175,4 @@
 				if ((this._DependencyId != value))
 				{
-					if (this._Plugin.HasLoadedOrAssignedValue)
-					{
-						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
-					}
 					this.OnDependencyIdChanging(value);
 					this.SendPropertyChanging();
@@ -195,72 +184,4 @@
 		}
 		
-		[Association(Name="Plugin_Dependency", Storage="_Plugin", ThisKey="DependencyId", OtherKey="Id", IsForeignKey=true)]
-		public Plugin Plugin
-		{
-			get
-			{
-				return this._Plugin.Entity;
-			}
-			set
-			{
-				Plugin previousValue = this._Plugin.Entity;
-				if (((previousValue != value) 
-							|| (this._Plugin.HasLoadedOrAssignedValue == false)))
-				{
-					this.SendPropertyChanging();
-					if ((previousValue != null))
-					{
-						this._Plugin.Entity = null;
-						previousValue.Dependencies.Remove(this);
-					}
-					this._Plugin.Entity = value;
-					if ((value != null))
-					{
-						value.Dependencies.Add(this);
-						this._DependencyId = value.Id;
-					}
-					else
-					{
-						this._DependencyId = default(long);
-					}
-					this.SendPropertyChanged("Plugin");
-				}
-			}
-		}
-		
-		[Association(Name="Plugin_Dependency1", Storage="_Plugin1", ThisKey="PluginId", OtherKey="Id", IsForeignKey=true)]
-		public Plugin Plugin1
-		{
-			get
-			{
-				return this._Plugin1.Entity;
-			}
-			set
-			{
-				Plugin previousValue = this._Plugin1.Entity;
-				if (((previousValue != value) 
-							|| (this._Plugin1.HasLoadedOrAssignedValue == false)))
-				{
-					this.SendPropertyChanging();
-					if ((previousValue != null))
-					{
-						this._Plugin1.Entity = null;
-						previousValue.Dependencies1.Remove(this);
-					}
-					this._Plugin1.Entity = value;
-					if ((value != null))
-					{
-						value.Dependencies1.Add(this);
-						this._PluginId = value.Id;
-					}
-					else
-					{
-						this._PluginId = default(long);
-					}
-					this.SendPropertyChanged("Plugin1");
-				}
-			}
-		}
-		
 		public event PropertyChangingEventHandler PropertyChanging;
 		
@@ -285,16 +206,29 @@
 	
 	[Table(Name="dbo.ProductPlugin")]
-	public partial class ProductPlugin
+	public partial class ProductPlugin : INotifyPropertyChanging, INotifyPropertyChanged
 	{
 		
+		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
+		
 		private long _ProductId;
 		
 		private long _PluginId;
 		
+    #region Extensibility Method Definitions
+    partial void OnLoaded();
+    partial void OnValidate(System.Data.Linq.ChangeAction action);
+    partial void OnCreated();
+    partial void OnProductIdChanging(long value);
+    partial void OnProductIdChanged();
+    partial void OnPluginIdChanging(long value);
+    partial void OnPluginIdChanged();
+    #endregion
+		
 		public ProductPlugin()
 		{
-		}
-		
-		[Column(Storage="_ProductId", DbType="BigInt NOT NULL")]
+			OnCreated();
+		}
+		
+		[Column(Storage="_ProductId", DbType="BigInt NOT NULL", IsPrimaryKey=true)]
 		public long ProductId
 		{
@@ -307,10 +241,14 @@
 				if ((this._ProductId != value))
 				{
+					this.OnProductIdChanging(value);
+					this.SendPropertyChanging();
 					this._ProductId = value;
-				}
-			}
-		}
-		
-		[Column(Storage="_PluginId", DbType="BigInt NOT NULL")]
+					this.SendPropertyChanged("ProductId");
+					this.OnProductIdChanged();
+				}
+			}
+		}
+		
+		[Column(Storage="_PluginId", DbType="BigInt NOT NULL", IsPrimaryKey=true)]
 		public long PluginId
 		{
@@ -323,6 +261,30 @@
 				if ((this._PluginId != value))
 				{
+					this.OnPluginIdChanging(value);
+					this.SendPropertyChanging();
 					this._PluginId = value;
-				}
+					this.SendPropertyChanged("PluginId");
+					this.OnPluginIdChanged();
+				}
+			}
+		}
+		
+		public event PropertyChangingEventHandler PropertyChanging;
+		
+		public event PropertyChangedEventHandler PropertyChanged;
+		
+		protected virtual void SendPropertyChanging()
+		{
+			if ((this.PropertyChanging != null))
+			{
+				this.PropertyChanging(this, emptyChangingEventArgs);
+			}
+		}
+		
+		protected virtual void SendPropertyChanged(String propertyName)
+		{
+			if ((this.PropertyChanged != null))
+			{
+				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
 			}
 		}
@@ -340,8 +302,4 @@
 		
 		private string _Version;
-		
-		private EntitySet<Dependency> _Dependencies;
-		
-		private EntitySet<Dependency> _Dependencies1;
 		
 		private EntityRef<PluginPackage> _PluginPackage;
@@ -361,6 +319,4 @@
 		public Plugin()
 		{
-			this._Dependencies = new EntitySet<Dependency>(new Action<Dependency>(this.attach_Dependencies), new Action<Dependency>(this.detach_Dependencies));
-			this._Dependencies1 = new EntitySet<Dependency>(new Action<Dependency>(this.attach_Dependencies1), new Action<Dependency>(this.detach_Dependencies1));
 			this._PluginPackage = default(EntityRef<PluginPackage>);
 			OnCreated();
@@ -424,30 +380,4 @@
 					this.OnVersionChanged();
 				}
-			}
-		}
-		
-		[Association(Name="Plugin_Dependency", Storage="_Dependencies", ThisKey="Id", OtherKey="DependencyId")]
-		public EntitySet<Dependency> Dependencies
-		{
-			get
-			{
-				return this._Dependencies;
-			}
-			set
-			{
-				this._Dependencies.Assign(value);
-			}
-		}
-		
-		[Association(Name="Plugin_Dependency1", Storage="_Dependencies1", ThisKey="Id", OtherKey="PluginId")]
-		public EntitySet<Dependency> Dependencies1
-		{
-			get
-			{
-				return this._Dependencies1;
-			}
-			set
-			{
-				this._Dependencies1.Assign(value);
 			}
 		}
@@ -500,28 +430,4 @@
 				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
 			}
-		}
-		
-		private void attach_Dependencies(Dependency entity)
-		{
-			this.SendPropertyChanging();
-			entity.Plugin = this;
-		}
-		
-		private void detach_Dependencies(Dependency entity)
-		{
-			this.SendPropertyChanging();
-			entity.Plugin = null;
-		}
-		
-		private void attach_Dependencies1(Dependency entity)
-		{
-			this.SendPropertyChanging();
-			entity.Plugin1 = this;
-		}
-		
-		private void detach_Dependencies1(Dependency entity)
-		{
-			this.SendPropertyChanging();
-			entity.Plugin1 = null;
 		}
 	}
@@ -707,5 +613,5 @@
 		}
 		
-		[Column(Storage="_Id", DbType="BigInt NOT NULL", IsPrimaryKey=true)]
+		[Column(Storage="_Id", AutoSync=AutoSync.OnInsert, DbType="BigInt NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
 		public long Id
 		{
Index: /branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.Test/PluginStoreTest.cs
===================================================================
--- /branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.Test/PluginStoreTest.cs	(revision 2765)
+++ /branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.Test/PluginStoreTest.cs	(revision 2766)
@@ -194,5 +194,9 @@
         // check if the updated file is returned
         byte[] actual = target.PluginFile(newPlugin);
-        Assert.AreEqual(expected, actual);
+        // check retrieved file
+        Assert.AreEqual(expected.Length, actual.Length);
+        for (int i = 0; i < expected.Length; i++) {
+          Assert.AreEqual(expected[i], actual[i]);
+        }
       }
       #endregion
@@ -236,5 +240,5 @@
         var plugin = new PluginDescription(pluginName, vers01, new PluginDescription[] { depPlugin, depPlugin });
         try {
-          target.Persist(depPlugin, enc.GetBytes("Zipped " + depName));
+          target.Persist(plugin, enc.GetBytes("Zipped " + depName));
           Assert.Fail("Expected ArgumentException");
         }
@@ -372,11 +376,5 @@
 
         // persist the plugin first
-        int oldCount = target.Products.Count();
         target.Persist(plugin1, enc.GetBytes("Zipped " + plugin1.Name));
-        target.Persist(product);
-        int newCount = target.Products.Count();
-        // make sure the store went through
-        Assert.AreEqual(oldCount + 1, newCount);
-
         try {
           target.Persist(product);
