public T ExecuteDb <T>(Func <ThreesixtyContext, T> invoke) { T result; using (var context = new ThreesixtyContext(DbOptions)) { using (var tr = context.Database.BeginTransaction()) { result = invoke.Invoke(context); context.SaveChanges(); tr.Commit(); } } return(result); }
public static void Initialize(ThreesixtyContext context) { context.Database.EnsureCreated(); // Adding first user if (!context.Users.Any()) { var regInfo = new RegisterInfo { Username = "******", Fullname = "Admin", Password = "******", PasswordConfirm = "admin123" }; var user = UserManager.CreateUser(regInfo); context.Users.Add(user); } context.SaveChanges(); }