diff --git a/realm_cli/AppDbContext.cs b/realm_cli/AppDbContext.cs index b942548..95bfe4d 100644 --- a/realm_cli/AppDbContext.cs +++ b/realm_cli/AppDbContext.cs @@ -12,7 +12,7 @@ public class AppDbContext: DbContext public AppDbContext() { SQLitePCL.Batteries_V2.Init(); - this.Database.EnsureCreated(); + //this.Database.EnsureCreated(); } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) diff --git a/realm_cli/Program.cs b/realm_cli/Program.cs index 9b9111e..846df22 100644 --- a/realm_cli/Program.cs +++ b/realm_cli/Program.cs @@ -4,6 +4,9 @@ using System.Collections.Concurrent; using System.ComponentModel; using System.Diagnostics; using Microsoft.Data.Sqlite; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Infrastructure.Internal; using MongoDB.Bson; using MongoDB.Bson.Serialization.Serializers; using realm_cli; @@ -202,7 +205,7 @@ async Task QueryLiveData() Console.WriteLine($"{(DateTime.Now - b).TotalSeconds} secs"); return null; } - +/* using (var db = GetDB()) { db.Write(() => @@ -210,7 +213,7 @@ using (var db = GetDB()) db.Add(new LiveDataMsg() {Id = "live", Uts = DateTimeOffset.Now, Text = "begin"}, update:true); }); } - +*/ //var t1 = Task.Run(() => Produce()); @@ -219,23 +222,28 @@ using (var db = GetDB()) //var t2 = ConsumeAsync(); //Task.WaitAll(t1, t2); +using (var ctx = new AppDbContext()) +{ + ctx.Database.EnsureCreated(); +} + var b = DateTime.Now; -using (var ctx = new AppDbContext()) +var builder = new DbContextOptionsBuilder(); + { - for (var i = 1; i != 1000; ++i) + for (var i = 1; i != 10000; ++i) { - - //{ + using (var ctx = new AppDbContext()) + { var s = new LiveDataState {ItemId = i, EcuId = (ushort) (i + 1), Value = (float) (i * 1.0)}; ctx.Add(s); //Console.WriteLine(ctx.Entry(s).Entity.ItemId); - //ctx.SaveChanges(); - //} - + ctx.SaveChanges(); + } + //ctx.SaveChanges(); } - ctx.SaveChanges(); } Console.WriteLine($"{(DateTime.Now - b).TotalSeconds}");