39 lines
781 B
C#
39 lines
781 B
C#
using Microsoft.EntityFrameworkCore;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
public class GamerContext : DbContext
|
|
{
|
|
public DbSet<Person> People { get; set; }
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
|
{
|
|
options.UseSqlite("DataSource=db.sqlite3");
|
|
}
|
|
}
|
|
|
|
public class Person
|
|
{
|
|
[Key]
|
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
public int Id { get; set; }
|
|
public string Name { get; set; }
|
|
public int Age { get; set; }
|
|
}
|
|
|
|
public class Program
|
|
{
|
|
public static void Main()
|
|
{
|
|
Console.WriteLine("hi");
|
|
|
|
var context = new GamerContext();
|
|
|
|
context.Add(new Person { Name = "John", Age = 30 });
|
|
context.SaveChanges();
|
|
}
|
|
}
|
|
|