This is the next step in my previous sample (see the previous post from this month). Now I want to add and delete products using my Web service and EF.
The problem I found: I had to go back to the database and set a cascade delete for the FK_ProductInventory_Product (because I forgot to do it initially). Then I did an update of the EF model. The .edmx file was not quite updated... in the SSDL section I found the expected code:<Association Name="FK_ProductInventory_Product"><End Role="Product" Type="ProductionModel.Store.Product" Multiplicity="1"><OnDelete Action="Cascade"> /></End>but on the CSDL section it was only:< Association Name="FK_ProductInventory_Product"><End Role="Product" Type="ProductionModel.Product" Multiplicity="1" ><End Role="ProductInventory" Type="ProductionModel.ProductInventory" Multiplicity="*"/></Association>>so I had to add manually the OnDelete part:<Association Name="FK_ProductInventory_Product">< End Role="Product" Type="ProductionModel.Product" Multiplicity="1" ><OnDelete Action="Cascade"></OnDelete></End ><End Role="ProductInventory" Type="ProductionModel.ProductInventory" Multiplicity="8"/></Association>and now it's working fine. I used VS2008 (.NET3.5 SP1) on Windows Vista. I will ask the product team if it's a known bug...
Here is the code (on the server side) for adding one product, adding a list of products and delete a product