{"action":"created","issue":{"url":"https://api.github.com/repos/BrightstarDB/BrightstarDB/issues/171","labels_url":"https://api.github.com/repos/BrightstarDB/BrightstarDB/issues/171/labels{/name}","comments_url":"https://api.github.com/repos/BrightstarDB/BrightstarDB/issues/171/comments","events_url":"https://api.github.com/repos/BrightstarDB/BrightstarDB/issues/171/events","html_url":"https://github.com/BrightstarDB/BrightstarDB/issues/171","id":56155821,"number":171,"title":"Cannot update entity on many side of 1:m relationship where key is composite","user":{"login":"kentcb","id":1901832,"avatar_url":"https://avatars.githubusercontent.com/u/1901832?v=3","gravatar_id":"","url":"https://api.github.com/users/kentcb","html_url":"https://github.com/kentcb","followers_url":"https://api.github.com/users/kentcb/followers","following_url":"https://api.github.com/users/kentcb/following{/other_user}","gists_url":"https://api.github.com/users/kentcb/gists{/gist_id}","starred_url":"https://api.github.com/users/kentcb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kentcb/subscriptions","organizations_url":"https://api.github.com/users/kentcb/orgs","repos_url":"https://api.github.com/users/kentcb/repos","events_url":"https://api.github.com/users/kentcb/events{/privacy}","received_events_url":"https://api.github.com/users/kentcb/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-01T07:43:25Z","updated_at":"2015-02-02T00:15:21Z","closed_at":"2015-02-01T13:20:22Z","body":"Sorry if I'm doing something dumb here, but the following fails (exception details below). This is a major blocker for me.\r\n\r\n```C#\r\n[Entity]\r\npublic interface ISupplier\r\n{\r\n    string Id\r\n    {\r\n        get;\r\n    }\r\n\r\n    ICollection<IProduct> Products\r\n    {\r\n        get;\r\n        set;\r\n    }\r\n}\r\n\r\n[Entity]\r\npublic interface IProduct\r\n{\r\n    [Identifier(KeyProperties = new[] { \"Supplier\", \"Code\" })]\r\n    string Id\r\n    {\r\n        get;\r\n    }\r\n\r\n    string Code\r\n    {\r\n        get;\r\n        set;\r\n    }\r\n\r\n    string Name\r\n    {\r\n        get;\r\n        set;\r\n    }\r\n\r\n    [InverseProperty(\"Products\")]\r\n    ISupplier Supplier\r\n    {\r\n        get;\r\n        set;\r\n    }\r\n}\r\n\r\nclass Program\r\n{\r\n    static void Main(string[] args)\r\n    {\r\n        var connectionString = \"type=embedded;storesdirectory=Stores;storename=Repro\";\r\n        var client = BrightstarService.GetClient(connectionString);\r\n\r\n        if (client.DoesStoreExist(\"Repro\"))\r\n        {\r\n            client.DeleteStore(\"Repro\");\r\n        }\r\n\r\n        using (var context = new MyEntityContext(connectionString))\r\n        {\r\n            var supplier = new Supplier\r\n            {\r\n                Id = \"acme\"\r\n            };\r\n            var product = new Product\r\n            {\r\n                Code = \"abc\",\r\n                Name = \"Widget\",\r\n                Supplier = supplier\r\n            };\r\n\r\n            context.Products.Add(product);\r\n            context.SaveChanges();\r\n        }\r\n\r\n        using (var context = new MyEntityContext(connectionString))\r\n        {\r\n            var supplier = context\r\n                .Suppliers\r\n                .Where(x => x.Id == \"acme\")\r\n                .First();\r\n            var product = new Product\r\n            {\r\n                Code = \"abc\",\r\n                Name = \"Widget Renamed\",\r\n                Supplier = supplier\r\n            };\r\n\r\n            product.Context = context;\r\n            //var trackedObjects = context.TrackedObjects.ToList();\r\n\r\n            // FAILS HERE WITH EXCEPTION BELOW\r\n            context.SaveChanges();\r\n        }\r\n\r\n        Console.WriteLine(\"DONE\");\r\n        Console.ReadKey();\r\n    }\r\n}\r\n```\r\nException details:\r\n```\r\nBrightstarDB.EntityFramework.UniqueConstraintViolationException was unhandled\r\nMessage: An unhandled exception of type 'BrightstarDB.EntityFramework.UniqueConstraintViolationException' occurred in BrightstarDB.dll\r\nAdditional information: One or more new resources have an identifier that conflicts with an existing resource of the same type.\r\n```"},"comment":{"url":"https://api.github.com/repos/BrightstarDB/BrightstarDB/issues/comments/72393010","html_url":"https://github.com/BrightstarDB/BrightstarDB/issues/171#issuecomment-72393010","issue_url":"https://api.github.com/repos/BrightstarDB/BrightstarDB/issues/171","id":72393010,"user":{"login":"kentcb","id":1901832,"avatar_url":"https://avatars.githubusercontent.com/u/1901832?v=3","gravatar_id":"","url":"https://api.github.com/users/kentcb","html_url":"https://github.com/kentcb","followers_url":"https://api.github.com/users/kentcb/followers","following_url":"https://api.github.com/users/kentcb/following{/other_user}","gists_url":"https://api.github.com/users/kentcb/gists{/gist_id}","starred_url":"https://api.github.com/users/kentcb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kentcb/subscriptions","organizations_url":"https://api.github.com/users/kentcb/orgs","repos_url":"https://api.github.com/users/kentcb/repos","events_url":"https://api.github.com/users/kentcb/events{/privacy}","received_events_url":"https://api.github.com/users/kentcb/received_events","type":"User","site_admin":false},"created_at":"2015-02-02T00:15:21Z","updated_at":"2015-02-02T00:15:21Z","body":"Thanks Kal. My reasoning for creating a new product versus looking up the existing one is as per #170. However, this at least gives me a way forward - it just means I have to manually copy the properties on the product from the external code into the product retrieved from the context."}}