예제 #1
0
        public static void Temporary_values_1()
        {
            Console.WriteLine($">>>> Sample: {nameof(Temporary_values_1)}");
            Console.WriteLine();

            Helpers.RecreateCleanDatabase();
            Helpers.PopulateDatabase();

            #region Temporary_values_1
            using var context = new BlogsContext();

            var blog = new Blog {
                Name = ".NET Blog"
            };

            context.Add(blog);

            Console.WriteLine($"Blog.Id set on entity is {blog.Id}");
            Console.WriteLine($"Blog.Id tracked by EF is {context.Entry(blog).Property(e => e.Id).CurrentValue}");
            #endregion

            Console.WriteLine();
        }
        public static void Relationship_fixup_2()
        {
            Console.WriteLine($">>>> Sample: {nameof(Relationship_fixup_2)}");
            Console.WriteLine();

            Helpers.RecreateCleanDatabase();
            Helpers.PopulateDatabase();

            #region Relationship_fixup_2
            using var context = new BlogsContext();

            var blogs = context.Blogs.ToList();
            Console.WriteLine(context.ChangeTracker.DebugView.LongView);

            var assets = context.Assets.ToList();
            Console.WriteLine(context.ChangeTracker.DebugView.LongView);

            var posts = context.Posts.ToList();
            Console.WriteLine(context.ChangeTracker.DebugView.LongView);
            #endregion

            Console.WriteLine();
        }