{"action":"created","issue":{"url":"https://api.github.com/repos/object/Simple.OData.Client/issues/68","labels_url":"https://api.github.com/repos/object/Simple.OData.Client/issues/68/labels{/name}","comments_url":"https://api.github.com/repos/object/Simple.OData.Client/issues/68/comments","events_url":"https://api.github.com/repos/object/Simple.OData.Client/issues/68/events","html_url":"https://github.com/object/Simple.OData.Client/issues/68","id":52615407,"number":68,"title":"Update Many to Many relationship causes Exception","user":{"login":"Allann","id":2005474,"avatar_url":"https://avatars.githubusercontent.com/u/2005474?v=3","gravatar_id":"","url":"https://api.github.com/users/Allann","html_url":"https://github.com/Allann","followers_url":"https://api.github.com/users/Allann/followers","following_url":"https://api.github.com/users/Allann/following{/other_user}","gists_url":"https://api.github.com/users/Allann/gists{/gist_id}","starred_url":"https://api.github.com/users/Allann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Allann/subscriptions","organizations_url":"https://api.github.com/users/Allann/orgs","repos_url":"https://api.github.com/users/Allann/repos","events_url":"https://api.github.com/users/Allann/events{/privacy}","received_events_url":"https://api.github.com/users/Allann/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2014-12-22T02:43:04Z","updated_at":"2015-03-26T10:14:23Z","closed_at":"2014-12-28T13:18:54Z","body":"Hi, not sure if this is something I have done wrong in my models as I haven't seen anybody post a similar error.  \r\n\r\nTo reproduce the exception you can use the following client code:\r\n```csharp\r\n    ICredentials credentials = CredentialCache.DefaultNetworkCredentials;\r\n    var settings = new ODataClientSettings(\"http://localhost:53172/\", credentials) { OnTrace = (x, y) => Debug.WriteLine(\"OData: \" + x, y) };\r\n    var client = new ODataClient(settings);\r\n    // get existing category\r\n    var category = await client.For<Category>().Filter(c => c.Title == \"Test\").FindEntryAsync();\r\n    Console.WriteLine(string.Join(\", \", category.Id, category.Title));\r\n    // get existing header\r\n    var header = await client.For<Header>().Filter(h => h.Title == \"Numeric Tests\").Expand(h => h.Categories).FindEntryAsync();\r\n    Console.WriteLine(string.Join(\", \", header.Id, header.Title, header.Title));\r\n    // add category to header\r\n    header.Categories.Add(category);\r\n    // update CategoryHeader table\r\n    await client.For<Header>().Key(header.Id).Set(header).UpdateEntryAsync();\r\n```\r\nClient Models (using typed api with matching namespaces):\r\n```csharp\r\nnamespace Jbssa.ElectronicForms.Domain\r\n{\r\n    public sealed class Category \r\n    {\r\n        public Category()\r\n        {\r\n            Headers = new Collection<Header>();\r\n        }\r\n        public Guid Id { get; set; }\r\n        public string Title { get; set; }\r\n        public ICollection<Header> Headers { get; set; } \r\n    }\r\n\r\n    public class Header\r\n    {\r\n        public Header()\r\n        {\r\n            Categories = new Collection<Category>();\r\n        }\r\n        public Guid Id { get; set; }\r\n        public string Title { get; set; }\r\n        public ICollection<Category> Categories { get; set; }\r\n    }\r\n}\r\n```\r\nServer MetaData (http://localhost:53172/$metadata):\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<edmx:Edmx Version=\"4.0\" xmlns:edmx=\"http://docs.oasis-open.org/odata/ns/edmx\">\r\n  <edmx:DataServices>\r\n    <Schema Namespace=\"Jbssa.ElectronicForms.Domain\" xmlns=\"http://docs.oasis-open.org/odata/ns/edm\">\r\n      <EntityType Name=\"Category\">\r\n        <Key>\r\n          <PropertyRef Name=\"Id\" />\r\n        </Key>\r\n        <Property Name=\"Title\" Type=\"Edm.String\" Nullable=\"false\" />\r\n        <Property Name=\"Id\" Type=\"Edm.Guid\" Nullable=\"false\" />\r\n        <NavigationProperty Name=\"Headers\" Type=\"Collection(Jbssa.ElectronicForms.Domain.Header)\" />\r\n      </EntityType>\r\n      <EntityType Name=\"Header\">\r\n        <Key>\r\n          <PropertyRef Name=\"Id\" />\r\n        </Key>\r\n        <Property Name=\"Title\" Type=\"Edm.String\" Nullable=\"false\" />\r\n        <Property Name=\"Id\" Type=\"Edm.Guid\" Nullable=\"false\" />\r\n        <NavigationProperty Name=\"Categories\" Type=\"Collection(Jbssa.ElectronicForms.Domain.Category)\" />\r\n      </EntityType>\r\n    </Schema>\r\n    <Schema Namespace=\"Default\" xmlns=\"http://docs.oasis-open.org/odata/ns/edm\">\r\n      <Action Name=\"AddStatistics\">\r\n        <Parameter Name=\"ActionKey\" Type=\"Edm.String\" Unicode=\"false\" />\r\n        <Parameter Name=\"PrimaryId\" Type=\"Edm.Guid\" Nullable=\"false\" />\r\n      </Action>\r\n      <Function Name=\"GetMasterEnvironment\">\r\n        <ReturnType Type=\"Jbssa.ElectronicForms.Domain.Master.ServerEnvironment\" />\r\n      </Function>\r\n      <EntityContainer Name=\"Container\">\r\n        <EntitySet Name=\"Categories\" EntityType=\"Jbssa.ElectronicForms.Domain.Category\">\r\n          <NavigationPropertyBinding Path=\"Headers\" Target=\"Headers\" />\r\n        </EntitySet>\r\n        <EntitySet Name=\"Headers\" EntityType=\"Jbssa.ElectronicForms.Domain.Header\">\r\n          <NavigationPropertyBinding Path=\"Categories\" Target=\"Categories\" />\r\n        </EntitySet>\r\n        <ActionImport Name=\"AddStatistics\" Action=\"Default.AddStatistics\" />\r\n        <FunctionImport Name=\"GetMasterEnvironment\" Function=\"Default.GetMasterEnvironment\" IncludeInServiceDocument=\"true\" />\r\n      </EntityContainer>\r\n    </Schema>\r\n  </edmx:DataServices>\r\n</edmx:Edmx>\r\n```\r\nException: \r\n    System.ArgumentNullException occurred\r\n      HResult=-2147467261\r\n      Message=Value cannot be null.\r\n    Parameter name: propertyInfo.Target\r\n      Source=Microsoft.OData.Edm\r\n      ParamName=propertyInfo.Target\r\n      StackTrace:\r\n           at Microsoft.OData.Edm.EdmUtil.CheckArgumentNull[T](T value, String parameterName)\r\n           at Microsoft.OData.Edm.Library.EdmNavigationProperty.CreateNavigationProperty(IEdmEntityType declaringType, EdmNavigationPropertyInfo propertyInfo)\r\n           at Microsoft.OData.Edm.Library.EdmEntityType.AddUnidirectionalNavigation(EdmNavigationPropertyInfo propertyInfo)\r\n           at Simple.OData.Client.V4.Adapter.EdmDeltaModel..ctor(IEdmModel source, IEdmEntityType entityType, IEnumerable`1 propertyNames)\r\n      InnerException: \r\n\r\nAs can be seen in the metadata read by the client, the navigation properties are recognised and when updated on the server (using the server models) the update occurs correctly so EF6.1.1 is doing the right thing with the models."},"comment":{"url":"https://api.github.com/repos/object/Simple.OData.Client/issues/comments/86436759","html_url":"https://github.com/object/Simple.OData.Client/issues/68#issuecomment-86436759","issue_url":"https://api.github.com/repos/object/Simple.OData.Client/issues/68","id":86436759,"user":{"login":"TresaL","id":11662091,"avatar_url":"https://avatars.githubusercontent.com/u/11662091?v=3","gravatar_id":"","url":"https://api.github.com/users/TresaL","html_url":"https://github.com/TresaL","followers_url":"https://api.github.com/users/TresaL/followers","following_url":"https://api.github.com/users/TresaL/following{/other_user}","gists_url":"https://api.github.com/users/TresaL/gists{/gist_id}","starred_url":"https://api.github.com/users/TresaL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TresaL/subscriptions","organizations_url":"https://api.github.com/users/TresaL/orgs","repos_url":"https://api.github.com/users/TresaL/repos","events_url":"https://api.github.com/users/TresaL/events{/privacy}","received_events_url":"https://api.github.com/users/TresaL/received_events","type":"User","site_admin":false},"created_at":"2015-03-26T10:14:22Z","updated_at":"2015-03-26T10:14:22Z","body":"Hi Allann, how did you make this work?\r\nclient.For<Category>().Key(primaryKey).Set(category).UpdateEntryAsync();\r\n I'm facing the same exception on one to many relationship entity update. Thanks"}}