public void Can_run_end_to_end_scenario()
        {
            //Demo of logging using Log
            using (var db = new BloggingContext())
            {
                db.ConfigureLogging(AppendLog);
                db.Database.EnsureDeleted();
                db.Database.EnsureCreated();
                db.Blogs.Add(new Blog {
                    BlogId = new Guid("b3279372-78f5-4c13-93c9-e9b281a5ed5b"), Url = "http://erikej.blogspot.com"
                });
                db.SaveChanges();

                var blogs = db.Blogs.ToList();

                Assert.True(_log.Contains(@"[Parameters=[@p0='b3279372-78f5-4c13-93c9-e9b281a5ed5b', @p1='http://erikej.blogspot.com' (Size = 4000)], CommandType='Text', CommandTimeout='0']
INSERT INTO [Blogs] ([BlogId], [Url])
VALUES (@p0, @p1)"));

                Assert.True(_log.Contains(@"[Parameters=[], CommandType='Text', CommandTimeout='0']
SELECT [b].[BlogId], [b].[Url]
FROM [Blogs] AS [b]"));

                Assert.Equal(1, blogs.Count);
                Assert.Equal("http://erikej.blogspot.com", blogs[0].Url);
            }
        }
示例#2
0
        public void Can_run_end_to_end_scenario()
        {
            using (var db = new BloggingContext())
            {
                db.ConfigureLogging(x => Debug.WriteLine(x));
                db.Database.EnsureDeleted();
                db.Database.EnsureCreated();
                db.Blogs.Add(new Blog {
                    Url = "http://erikej.blogspot.com"
                });
                db.SaveChanges();

                foreach (var entity in db.Model.GetEntityTypes())
                {
                    Console.WriteLine($" {entity.ClrType.Name} => {entity.SqlCe().TableName}");
                }


                var blogs = db.Blogs.ToList();

                Assert.Equal(blogs.Count, 1);
                Assert.Equal(blogs[0].Url, "http://erikej.blogspot.com");
            }
        }