diff --git a/lottery-co-uk-scraper.data/CommitToDatabase.cs b/lottery-co-uk-scraper.data/CommitToDatabase.cs index 1f85b98..d53924e 100644 --- a/lottery-co-uk-scraper.data/CommitToDatabase.cs +++ b/lottery-co-uk-scraper.data/CommitToDatabase.cs @@ -7,7 +7,7 @@ namespace lottery_co_uk_scraper.data { public static void SaveModelToDatabase(LottoResult lottoResults) { - using var dbContext = new LottoDbContext(new DbContextOptions()); + using var dbContext = new LotteryContext(); dbContext.Database.EnsureCreated(); dbContext.LottoResults.Add(lottoResults); diff --git a/lottery-co-uk-scraper.data/DbContext.cs b/lottery-co-uk-scraper.data/DbContext.cs deleted file mode 100644 index c50b67c..0000000 --- a/lottery-co-uk-scraper.data/DbContext.cs +++ /dev/null @@ -1,20 +0,0 @@ -using lottery_co_uk_scraper.core.Models; -using Microsoft.EntityFrameworkCore; - -namespace lottery_co_uk_scraper.data -{ - public class LottoDbContext(DbContextOptions options) : DbContext(options) - { - public DbSet LottoResults { get; set; } - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.Entity().HasKey(e => e.Id); - } - - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - optionsBuilder.UseSqlServer("Server=(localdb)\\mssqllocaldb;Database=Lotto;Trusted_Connection=True;"); - } - } -} \ No newline at end of file diff --git a/lottery-co-uk-scraper.data/LotteryDbContext.cs b/lottery-co-uk-scraper.data/LotteryDbContext.cs new file mode 100644 index 0000000..5ab19a4 --- /dev/null +++ b/lottery-co-uk-scraper.data/LotteryDbContext.cs @@ -0,0 +1,23 @@ +using lottery_co_uk_scraper.core.Models; +using Microsoft.EntityFrameworkCore; + +namespace lottery_co_uk_scraper.data +{ + public class LotteryContext : DbContext + { + public DbSet LottoResults { get; set; } + + public LotteryContext() + { + + } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (!optionsBuilder.IsConfigured) + { + optionsBuilder.UseSqlServer(""); + } + } + } +} \ No newline at end of file diff --git a/lottery-co-uk-scraper.data/Migrations/20240207223729_InitialCreate.Designer.cs b/lottery-co-uk-scraper.data/Migrations/20240207223729_InitialCreate.Designer.cs new file mode 100644 index 0000000..6e1b576 --- /dev/null +++ b/lottery-co-uk-scraper.data/Migrations/20240207223729_InitialCreate.Designer.cs @@ -0,0 +1,161 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using lottery_co_uk_scraper.data; + +#nullable disable + +namespace lottery_co_uk_scraper.data.Migrations +{ + [DbContext(typeof(LotteryContext))] + [Migration("20240207223729_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("lottery_co_uk_scraper.core.Models.LottoResult", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BallSetUsed") + .HasColumnType("int"); + + b.Property("DrawDate") + .HasColumnType("date"); + + b.Property("DrawNumber") + .HasColumnType("int"); + + b.Property("DrawnBall1") + .HasColumnType("int"); + + b.Property("DrawnBall2") + .HasColumnType("int"); + + b.Property("DrawnBall3") + .HasColumnType("int"); + + b.Property("DrawnBall4") + .HasColumnType("int"); + + b.Property("DrawnBall5") + .HasColumnType("int"); + + b.Property("DrawnBall6") + .HasColumnType("int"); + + b.Property("DrawnBonusBall") + .HasColumnType("int"); + + b.Property("MachineUsed") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Matched2Prize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched2PrizeFund") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched2RolldownPrize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched3Prize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched3PrizeFund") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched3RolldownPrize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched4Prize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched4PrizeFund") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched4RolldownPrize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched5PlusBonusPrize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched5PlusBonusPrizeFund") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched5PlusBonusRolldownPrize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched5Prize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched5PrizeFund") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched5RolldownPrize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched6Prize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched6PrizeFund") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched6RolldownPrize") + .HasColumnType("decimal(18,2)"); + + b.Property("Rolldown") + .HasColumnType("bit"); + + b.Property("Rollover") + .HasColumnType("bit"); + + b.Property("TotalMatched2") + .HasColumnType("decimal(18,2)"); + + b.Property("TotalMatched3") + .HasColumnType("decimal(18,2)"); + + b.Property("TotalMatched4") + .HasColumnType("decimal(18,2)"); + + b.Property("TotalMatched5") + .HasColumnType("decimal(18,2)"); + + b.Property("TotalMatched5PlusBonus") + .HasColumnType("decimal(18,2)"); + + b.Property("TotalMatched6") + .HasColumnType("decimal(18,2)"); + + b.Property("TotalPrizeFund") + .HasColumnType("decimal(18,2)"); + + b.Property("TotalWinners") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("LottoResults"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/lottery-co-uk-scraper.data/Migrations/20240207223729_InitialCreate.cs b/lottery-co-uk-scraper.data/Migrations/20240207223729_InitialCreate.cs new file mode 100644 index 0000000..ae24e12 --- /dev/null +++ b/lottery-co-uk-scraper.data/Migrations/20240207223729_InitialCreate.cs @@ -0,0 +1,73 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace lottery_co_uk_scraper.data.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "LottoResults", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + DrawDate = table.Column(type: "date", nullable: false), + DrawNumber = table.Column(type: "int", nullable: false), + Rollover = table.Column(type: "bit", nullable: false), + Rolldown = table.Column(type: "bit", nullable: false), + BallSetUsed = table.Column(type: "int", nullable: false), + MachineUsed = table.Column(type: "nvarchar(max)", nullable: false), + DrawnBall1 = table.Column(type: "int", nullable: false), + DrawnBall2 = table.Column(type: "int", nullable: false), + DrawnBall3 = table.Column(type: "int", nullable: false), + DrawnBall4 = table.Column(type: "int", nullable: false), + DrawnBall5 = table.Column(type: "int", nullable: false), + DrawnBall6 = table.Column(type: "int", nullable: false), + DrawnBonusBall = table.Column(type: "int", nullable: false), + TotalMatched2 = table.Column(type: "decimal(18,2)", nullable: false), + Matched2Prize = table.Column(type: "decimal(18,2)", nullable: false), + Matched2PrizeFund = table.Column(type: "decimal(18,2)", nullable: false), + Matched2RolldownPrize = table.Column(type: "decimal(18,2)", nullable: false), + TotalMatched3 = table.Column(type: "decimal(18,2)", nullable: false), + Matched3Prize = table.Column(type: "decimal(18,2)", nullable: false), + Matched3PrizeFund = table.Column(type: "decimal(18,2)", nullable: false), + Matched3RolldownPrize = table.Column(type: "decimal(18,2)", nullable: false), + TotalMatched4 = table.Column(type: "decimal(18,2)", nullable: false), + Matched4Prize = table.Column(type: "decimal(18,2)", nullable: false), + Matched4PrizeFund = table.Column(type: "decimal(18,2)", nullable: false), + Matched4RolldownPrize = table.Column(type: "decimal(18,2)", nullable: false), + TotalMatched5 = table.Column(type: "decimal(18,2)", nullable: false), + Matched5Prize = table.Column(type: "decimal(18,2)", nullable: false), + Matched5PrizeFund = table.Column(type: "decimal(18,2)", nullable: false), + TotalMatched5PlusBonus = table.Column(type: "decimal(18,2)", nullable: false), + Matched5RolldownPrize = table.Column(type: "decimal(18,2)", nullable: false), + Matched5PlusBonusPrize = table.Column(type: "decimal(18,2)", nullable: false), + Matched5PlusBonusPrizeFund = table.Column(type: "decimal(18,2)", nullable: false), + Matched5PlusBonusRolldownPrize = table.Column(type: "decimal(18,2)", nullable: false), + TotalMatched6 = table.Column(type: "decimal(18,2)", nullable: false), + Matched6Prize = table.Column(type: "decimal(18,2)", nullable: false), + Matched6PrizeFund = table.Column(type: "decimal(18,2)", nullable: false), + Matched6RolldownPrize = table.Column(type: "decimal(18,2)", nullable: false), + TotalWinners = table.Column(type: "int", nullable: false), + TotalPrizeFund = table.Column(type: "decimal(18,2)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_LottoResults", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "LottoResults"); + } + } +} diff --git a/lottery-co-uk-scraper.data/Migrations/LotteryContextModelSnapshot.cs b/lottery-co-uk-scraper.data/Migrations/LotteryContextModelSnapshot.cs new file mode 100644 index 0000000..bc58dc6 --- /dev/null +++ b/lottery-co-uk-scraper.data/Migrations/LotteryContextModelSnapshot.cs @@ -0,0 +1,158 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using lottery_co_uk_scraper.data; + +#nullable disable + +namespace lottery_co_uk_scraper.data.Migrations +{ + [DbContext(typeof(LotteryContext))] + partial class LotteryContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("lottery_co_uk_scraper.core.Models.LottoResult", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BallSetUsed") + .HasColumnType("int"); + + b.Property("DrawDate") + .HasColumnType("date"); + + b.Property("DrawNumber") + .HasColumnType("int"); + + b.Property("DrawnBall1") + .HasColumnType("int"); + + b.Property("DrawnBall2") + .HasColumnType("int"); + + b.Property("DrawnBall3") + .HasColumnType("int"); + + b.Property("DrawnBall4") + .HasColumnType("int"); + + b.Property("DrawnBall5") + .HasColumnType("int"); + + b.Property("DrawnBall6") + .HasColumnType("int"); + + b.Property("DrawnBonusBall") + .HasColumnType("int"); + + b.Property("MachineUsed") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Matched2Prize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched2PrizeFund") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched2RolldownPrize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched3Prize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched3PrizeFund") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched3RolldownPrize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched4Prize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched4PrizeFund") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched4RolldownPrize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched5PlusBonusPrize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched5PlusBonusPrizeFund") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched5PlusBonusRolldownPrize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched5Prize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched5PrizeFund") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched5RolldownPrize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched6Prize") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched6PrizeFund") + .HasColumnType("decimal(18,2)"); + + b.Property("Matched6RolldownPrize") + .HasColumnType("decimal(18,2)"); + + b.Property("Rolldown") + .HasColumnType("bit"); + + b.Property("Rollover") + .HasColumnType("bit"); + + b.Property("TotalMatched2") + .HasColumnType("decimal(18,2)"); + + b.Property("TotalMatched3") + .HasColumnType("decimal(18,2)"); + + b.Property("TotalMatched4") + .HasColumnType("decimal(18,2)"); + + b.Property("TotalMatched5") + .HasColumnType("decimal(18,2)"); + + b.Property("TotalMatched5PlusBonus") + .HasColumnType("decimal(18,2)"); + + b.Property("TotalMatched6") + .HasColumnType("decimal(18,2)"); + + b.Property("TotalPrizeFund") + .HasColumnType("decimal(18,2)"); + + b.Property("TotalWinners") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("LottoResults"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/lottery-co-uk-scraper.data/lottery-co-uk-scraper.data.csproj b/lottery-co-uk-scraper.data/lottery-co-uk-scraper.data.csproj index e94bfe0..3bd4b8e 100644 --- a/lottery-co-uk-scraper.data/lottery-co-uk-scraper.data.csproj +++ b/lottery-co-uk-scraper.data/lottery-co-uk-scraper.data.csproj @@ -10,6 +10,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/lottery-co-uk-scraper/lottery-co-uk-scraper.csproj b/lottery-co-uk-scraper/lottery-co-uk-scraper.csproj index 5713be8..36eb585 100644 --- a/lottery-co-uk-scraper/lottery-co-uk-scraper.csproj +++ b/lottery-co-uk-scraper/lottery-co-uk-scraper.csproj @@ -10,6 +10,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive +