Added some migration, address object

This commit is contained in:
2021-03-07 08:39:52 +01:00
parent bd20b3b9d3
commit f7dc96cd5f
7 changed files with 247 additions and 0 deletions

18
DataDomain/Address.cs Normal file
View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataDomain
{
public class Address
{
public int Id { get; set; }
public string Gata { get; set; }
public string Gata2 { get; set; }
public int PostNr { get; set; }
public string PostOrt { get; set; }
public string Nation { get; set; }
}
}

View File

@ -13,5 +13,8 @@ namespace DataDomain
public string LastName { get; set; }
public string NickName { get; set; }
public DateTime? Born { get; set; }
public string Comments { get; set; }
public int HomeAddress { get; set; }
public int InvoiceAddress { get; set; }
}
}

View File

@ -0,0 +1,125 @@
// <auto-generated />
using System;
using DatamodelLibrary;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace DatamodelLibrary.Migrations
{
[DbContext(typeof(StockContext))]
[Migration("20210306151633_completion_person_address")]
partial class completion_person_address
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.3");
modelBuilder.Entity("DataDomain.Address", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Gata")
.HasColumnType("TEXT");
b.Property<string>("Gata2")
.HasColumnType("TEXT");
b.Property<string>("Nation")
.HasColumnType("TEXT");
b.Property<int>("PostNr")
.HasColumnType("INTEGER");
b.Property<string>("PostOrt")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Addresses");
});
modelBuilder.Entity("DataDomain.Person", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime?>("Born")
.HasColumnType("TEXT");
b.Property<string>("Comments")
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.HasColumnType("TEXT");
b.Property<int>("HomeAddress")
.HasColumnType("INTEGER");
b.Property<int>("InvoiceAddress")
.HasColumnType("INTEGER");
b.Property<string>("LastName")
.HasColumnType("TEXT");
b.Property<string>("NickName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Persons");
});
modelBuilder.Entity("DataDomain.StockMember", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("ActAmount")
.HasColumnType("INTEGER");
b.Property<DateTime?>("ActDate")
.HasColumnType("TEXT");
b.Property<decimal>("ActValue")
.HasColumnType("TEXT");
b.Property<DateTime>("BuyDate")
.HasColumnType("TEXT");
b.Property<decimal>("BuyValue")
.HasColumnType("TEXT");
b.Property<string>("Comment")
.HasColumnType("TEXT");
b.Property<long>("PostAmount")
.HasColumnType("INTEGER");
b.Property<DateTime?>("SoldDate")
.HasColumnType("TEXT");
b.Property<decimal?>("SoldValue")
.HasColumnType("TEXT");
b.Property<string>("StockExtId")
.HasColumnType("TEXT");
b.Property<string>("StockId")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Stocks");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,65 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace DatamodelLibrary.Migrations
{
public partial class completion_person_address : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Comments",
table: "Persons",
type: "TEXT",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "HomeAddress",
table: "Persons",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "InvoiceAddress",
table: "Persons",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "Addresses",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Gata = table.Column<string>(type: "TEXT", nullable: true),
Gata2 = table.Column<string>(type: "TEXT", nullable: true),
PostNr = table.Column<int>(type: "INTEGER", nullable: false),
PostOrt = table.Column<string>(type: "TEXT", nullable: true),
Nation = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Addresses", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Addresses");
migrationBuilder.DropColumn(
name: "Comments",
table: "Persons");
migrationBuilder.DropColumn(
name: "HomeAddress",
table: "Persons");
migrationBuilder.DropColumn(
name: "InvoiceAddress",
table: "Persons");
}
}
}

View File

@ -16,6 +16,32 @@ namespace DatamodelLibrary.Migrations
modelBuilder
.HasAnnotation("ProductVersion", "5.0.3");
modelBuilder.Entity("DataDomain.Address", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Gata")
.HasColumnType("TEXT");
b.Property<string>("Gata2")
.HasColumnType("TEXT");
b.Property<string>("Nation")
.HasColumnType("TEXT");
b.Property<int>("PostNr")
.HasColumnType("INTEGER");
b.Property<string>("PostOrt")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Addresses");
});
modelBuilder.Entity("DataDomain.Person", b =>
{
b.Property<int>("Id")
@ -25,9 +51,18 @@ namespace DatamodelLibrary.Migrations
b.Property<DateTime?>("Born")
.HasColumnType("TEXT");
b.Property<string>("Comments")
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.HasColumnType("TEXT");
b.Property<int>("HomeAddress")
.HasColumnType("INTEGER");
b.Property<int>("InvoiceAddress")
.HasColumnType("INTEGER");
b.Property<string>("LastName")
.HasColumnType("TEXT");

View File

@ -12,6 +12,7 @@ namespace DatamodelLibrary
{
public DbSet<StockMember> Stocks { get; set; }
public DbSet<Person> Persons { get; set; }
public DbSet<Address> Addresses { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite("Data Source=Stocks.db");

Binary file not shown.