{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3147","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3147/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3147/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3147/events","html_url":"https://github.com/aspnet/EntityFramework/issues/3147","id":106727977,"number":3147,"title":"InvalidOperationException: A circular dependency was detected","user":{"login":"TheMadKow","id":5797896,"avatar_url":"https://avatars.githubusercontent.com/u/5797896?v=3","gravatar_id":"","url":"https://api.github.com/users/TheMadKow","html_url":"https://github.com/TheMadKow","followers_url":"https://api.github.com/users/TheMadKow/followers","following_url":"https://api.github.com/users/TheMadKow/following{/other_user}","gists_url":"https://api.github.com/users/TheMadKow/gists{/gist_id}","starred_url":"https://api.github.com/users/TheMadKow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheMadKow/subscriptions","organizations_url":"https://api.github.com/users/TheMadKow/orgs","repos_url":"https://api.github.com/users/TheMadKow/repos","events_url":"https://api.github.com/users/TheMadKow/events{/privacy}","received_events_url":"https://api.github.com/users/TheMadKow/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aspnet/EntityFramework/labels/bug","name":"bug","color":"f7c6c7"},{"url":"https://api.github.com/repos/aspnet/EntityFramework/labels/pri0","name":"pri0","color":"e11d21"}],"state":"open","locked":false,"assignee":{"login":"smitpatel","id":1528107,"avatar_url":"https://avatars.githubusercontent.com/u/1528107?v=3","gravatar_id":"","url":"https://api.github.com/users/smitpatel","html_url":"https://github.com/smitpatel","followers_url":"https://api.github.com/users/smitpatel/followers","following_url":"https://api.github.com/users/smitpatel/following{/other_user}","gists_url":"https://api.github.com/users/smitpatel/gists{/gist_id}","starred_url":"https://api.github.com/users/smitpatel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smitpatel/subscriptions","organizations_url":"https://api.github.com/users/smitpatel/orgs","repos_url":"https://api.github.com/users/smitpatel/repos","events_url":"https://api.github.com/users/smitpatel/events{/privacy}","received_events_url":"https://api.github.com/users/smitpatel/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/aspnet/EntityFramework/milestones/17","html_url":"https://github.com/aspnet/EntityFramework/milestones/7.0.0-rc1","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/milestones/17/labels","id":1311414,"number":17,"title":"7.0.0-rc1","description":"","creator":{"login":"rowanmiller","id":4741851,"avatar_url":"https://avatars.githubusercontent.com/u/4741851?v=3","gravatar_id":"","url":"https://api.github.com/users/rowanmiller","html_url":"https://github.com/rowanmiller","followers_url":"https://api.github.com/users/rowanmiller/followers","following_url":"https://api.github.com/users/rowanmiller/following{/other_user}","gists_url":"https://api.github.com/users/rowanmiller/gists{/gist_id}","starred_url":"https://api.github.com/users/rowanmiller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rowanmiller/subscriptions","organizations_url":"https://api.github.com/users/rowanmiller/orgs","repos_url":"https://api.github.com/users/rowanmiller/repos","events_url":"https://api.github.com/users/rowanmiller/events{/privacy}","received_events_url":"https://api.github.com/users/rowanmiller/received_events","type":"User","site_admin":false},"open_issues":100,"closed_issues":1,"state":"open","created_at":"2015-09-17T20:13:31Z","updated_at":"2015-09-18T19:19:59Z","due_on":"2015-11-30T08:00:00Z","closed_at":null},"comments":7,"created_at":"2015-09-16T08:48:32Z","updated_at":"2015-09-20T18:29:32Z","closed_at":null,"body":"Hi, \r\nWorking with the new dnx-clr-win-x86.1.0.0-Beta7.\r\n\r\nI'm getting the following message : \r\nInvalidOperationException: A circular dependency was detected: 'Schema' {'FutureId'} -> 'Occurrence' {'ID'}, 'Occurrence' {'SchemaID'} -> 'Schema' {'ID'}, 'OccurrenceHistory' {'OccurrenceID'} -> 'Occurrence' {'ID'}.\r\n\r\nWhere classes architecture is :\r\n- Schema holds all Occurrences under \"OccurrenceHistory\" enumerable.\r\n- Schema holds Future instance of the occurrence.\r\n- Schema holds Past instance of that occurrence.\r\n(that is, future is the next link in the chain, and past is the previous link in the chain. the history refers to all links whatsoever)\r\n\r\nSo, i'm not so sure why i get this error, it should work (unless i'm missing something), \r\nit worked on Beta6 but had some other issues, where it wasn't able to load the Future item with .Include.\r\n\r\nThanks,\r\nEliran. "},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/141819781","html_url":"https://github.com/aspnet/EntityFramework/issues/3147#issuecomment-141819781","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3147","id":141819781,"user":{"login":"TheMadKow","id":5797896,"avatar_url":"https://avatars.githubusercontent.com/u/5797896?v=3","gravatar_id":"","url":"https://api.github.com/users/TheMadKow","html_url":"https://github.com/TheMadKow","followers_url":"https://api.github.com/users/TheMadKow/followers","following_url":"https://api.github.com/users/TheMadKow/following{/other_user}","gists_url":"https://api.github.com/users/TheMadKow/gists{/gist_id}","starred_url":"https://api.github.com/users/TheMadKow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheMadKow/subscriptions","organizations_url":"https://api.github.com/users/TheMadKow/orgs","repos_url":"https://api.github.com/users/TheMadKow/repos","events_url":"https://api.github.com/users/TheMadKow/events{/privacy}","received_events_url":"https://api.github.com/users/TheMadKow/received_events","type":"User","site_admin":false},"created_at":"2015-09-20T18:29:32Z","updated_at":"2015-09-20T18:29:32Z","body":"@smitpatel , Hey,\r\nSorry for not including this info - the error is only at run time, when trying to create a new Schema and attach an occurrence, under \"await AppContext.SaveChangesAsync()\".\r\n\r\nI'm entering partial code again.\r\n\r\n\r\n        public async Task<IActionResult> Create(CreateUpdatePostit model)\r\n        {\r\n            Logger.LogInformation($\"User {AppUser().FullName} requested to CREATE Post-it {model.ID}\");\r\n            var assingee = AppContext.Users.FirstOrDefault(x => x.Id == model.WhoId);\r\n            \r\n            if (assingee == null || !ModelState.IsValid)\r\n            {\r\n                @ViewBag.Message = \"Create new Post-it\";\r\n                @ViewBag.Title = \"Create New\";\r\n                model.PopulateData(this, DataItems.AppUser | DataItems.Departments);\r\n                return View(model);\r\n            }\r\n\r\n            CreateHelper(assingee, model);\r\n            var uRes = await AppContext.SaveChangesAsync();\r\n            return RedirectToAction(\"ByMe\", \"Postits\", uRes > 0 \r\n                ? new { msg = \"Successfully create the Post-it\", msgType = \"success\" } \r\n                : new { msg = \"Failed to create the Post-it\", msgType = \"fail\" });\r\n        }\r\n\r\n\r\n        private Schema CreateHelper(ApplicationUser user, CreateUpdatePostit model)\r\n        {\r\n            var schema = model.CreateSchema();\r\n            schema.WhoString = user.FullName;\r\n\r\n            var cUser = AppUser();\r\n            schema.CreatorId = cUser.Id;\r\n            schema.CreatorName = cUser.FullName;\r\n            schema.CreationUTC = DateTime.UtcNow;\r\n            schema.IsRepeat = schema.When(cUser.Preferences.DateType).IsRepeat;\r\n\r\n            schema.Last = HistoryActionType.Created;\r\n            var history = new Schemahistory()\r\n            {\r\n                User = cUser,\r\n                WhenUTC = DateTime.UtcNow,\r\n                What = HistoryActionType.Created.TranslateToHistory(AppContext)\r\n            };\r\n\r\n            schema.History.Add(history);\r\n            var occr = OccurrenceBuilder.BuildNext(schema, null, cUser.Preferences.DateType, cUser.Location.TimeZone);\r\n            schema.Occurrences.Add(occr);\r\n            var occrHistory = new OccurrenceHistory()\r\n            {\r\n                User = cUser,\r\n                WhenUTC = DateTime.UtcNow,\r\n                What = HistoryActionType.Opened.TranslateToHistory(AppContext),\r\n            };\r\n            occr.History.Add(occrHistory);\r\n\r\n            AppContext.OccurrenceHistory.Add(occrHistory);\r\n            AppContext.Occurrences.Add(occr);\r\n            AppContext.SchemaHistory.Add(history);\r\n\r\n            schema.FutureId = occr.ID;\r\n            AppContext.Schemas.Add(schema);\r\n            //TODOoccr.SchemaID = schema.ID;\r\n\r\n            schema.Tags = new List<SchemaTag>();\r\n            foreach (var tag in model.TagsLine.SplitCsv())\r\n            {\r\n                var tagitem = AppContext.Tags.FirstOrDefault(x => x.ID.CompareToString(tag));\r\n                var schemaTag = new SchemaTag\r\n                {\r\n                    SchemaId = schema.ID,\r\n                    Schema = schema,\r\n                    Tag = tagitem\r\n                };\r\n\r\n                if (tagitem != null)\r\n                {\r\n                    tagitem.LastUsed = DateTime.UtcNow;\r\n                    AppContext.Tags.Update(tagitem);\r\n                }\r\n\r\n                schema.Tags.Add(schemaTag);\r\n                AppContext.SchemaTags.Add(schemaTag);\r\n            }\r\n\r\n            return schema;\r\n        }"}}