New version
This commit is contained in:
19
Drab.LocalDb/Drab.LocalDb.csproj
Normal file
19
Drab.LocalDb/Drab.LocalDb.csproj
Normal file
@@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0-windows</TargetFramework>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.7"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.7"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="9.0.7"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Migrations"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
16
Drab.LocalDb/Entities/OrderDb.cs
Normal file
16
Drab.LocalDb/Entities/OrderDb.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Drab.LocalDb.Entities;
|
||||
|
||||
public class OrderDb
|
||||
{
|
||||
[Key]
|
||||
public long OrderId { get; set; }
|
||||
public long DokId { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public bool IsPrinted { get; set; }
|
||||
public string Filename { get; set; }
|
||||
public string Shop { get; set; }
|
||||
public string OrderNumber { get; set; }
|
||||
}
|
||||
6
Drab.LocalDb/IoC/ILocalDbConfiguration.cs
Normal file
6
Drab.LocalDb/IoC/ILocalDbConfiguration.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Drab.LocalDb.IoC;
|
||||
|
||||
public interface ILocalDbConfiguration
|
||||
{
|
||||
public string ConnectionString { get; set; }
|
||||
}
|
||||
13
Drab.LocalDb/IoC/IocLocalDbRegister.cs
Normal file
13
Drab.LocalDb/IoC/IocLocalDbRegister.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Drab.LocalDb.IoC;
|
||||
|
||||
public static class IocLocalDbRegister
|
||||
{
|
||||
public static IServiceCollection AddLocalDatabase(this IServiceCollection services, ILocalDbConfiguration localDbConfiguration)
|
||||
{
|
||||
services.AddDbContext<LocalDbContext>(cx => cx.UseSqlite(localDbConfiguration.ConnectionString));
|
||||
return services;
|
||||
}
|
||||
}
|
||||
18
Drab.LocalDb/LocalDbContext.cs
Normal file
18
Drab.LocalDb/LocalDbContext.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Drab.LocalDb.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Drab.LocalDb;
|
||||
|
||||
public class LocalDbContext : DbContext
|
||||
{
|
||||
public LocalDbContext()
|
||||
{
|
||||
}
|
||||
|
||||
public LocalDbContext(DbContextOptions<LocalDbContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<OrderDb> Orders { get; set; }
|
||||
}
|
||||
52
Drab.LocalDb/Migrations/20211101180516_Initial.Designer.cs
generated
Normal file
52
Drab.LocalDb/Migrations/20211101180516_Initial.Designer.cs
generated
Normal file
@@ -0,0 +1,52 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Drab.LocalDb;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace Drab.LocalDb.Migrations
|
||||
{
|
||||
[DbContext(typeof(LocalDbContext))]
|
||||
[Migration("20211101180516_Initial")]
|
||||
partial class Initial
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "5.0.11");
|
||||
|
||||
modelBuilder.Entity("Drab.LocalDb.Entities.OrderDb", b =>
|
||||
{
|
||||
b.Property<long>("OrderId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<long>("DokId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Filename")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("IsPrinted")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("OrderNumber")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Shop")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("OrderId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
35
Drab.LocalDb/Migrations/20211101180516_Initial.cs
Normal file
35
Drab.LocalDb/Migrations/20211101180516_Initial.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Drab.LocalDb.Migrations
|
||||
{
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
OrderId = table.Column<long>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
DokId = table.Column<long>(type: "INTEGER", nullable: false),
|
||||
Created = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
IsPrinted = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||
Filename = table.Column<string>(type: "TEXT", nullable: true),
|
||||
Shop = table.Column<string>(type: "TEXT", nullable: true),
|
||||
OrderNumber = table.Column<string>(type: "TEXT", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.OrderId);
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
}
|
||||
}
|
||||
}
|
||||
50
Drab.LocalDb/Migrations/LocalDbContextModelSnapshot.cs
Normal file
50
Drab.LocalDb/Migrations/LocalDbContextModelSnapshot.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Drab.LocalDb;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace Drab.LocalDb.Migrations
|
||||
{
|
||||
[DbContext(typeof(LocalDbContext))]
|
||||
partial class LocalDbContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "5.0.11");
|
||||
|
||||
modelBuilder.Entity("Drab.LocalDb.Entities.OrderDb", b =>
|
||||
{
|
||||
b.Property<long>("OrderId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<long>("DokId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Filename")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("IsPrinted")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("OrderNumber")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Shop")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("OrderId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user