private void button4_Click(object sender, EventArgs e) { using (SqliteDbContext context = new SqliteDbContext()) { dataGridView1.DataSource = context.PersonDbContext.ToList(); } }
private void button3_Click(object sender, EventArgs e) { using (SqliteDbContext context = new SqliteDbContext()) { PersonEntity person = new PersonEntity(); person.Id = Guid.NewGuid().ToString("N"); person.Name = "晓明" + new Random().Next(); person.Sex = new Random().Next() % 2 == 0?"男":"女"; person.Age = new Random().Next(); context.PersonDbContext.Add(person); context.SaveChanges(); } }