sos
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using ConsoleApp1.data.model;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Type = ConsoleApp1.data.model.Type;
|
||||
|
||||
namespace ConsoleApp1.data;
|
||||
|
||||
public class PokemonContext : DbContext
|
||||
{
|
||||
public DbSet<Type> Types { get; set; }
|
||||
public DbSet<Stat> Stats { get; set; }
|
||||
public DbSet<Ability> Abilities { get; set; }
|
||||
|
||||
public DbSet<Pokemon> Pokemons { get; set; }
|
||||
public DbSet<PokemonType> PokemonsTypes { get; set; }
|
||||
public DbSet<PokemonStat> PokemonsStats { get; set; }
|
||||
public DbSet<PokemonAbility> PokemonsAbilitys { get; set; }
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
optionsBuilder.UseNpgsql("Username=postgres;Password=mysecretpassword;Host=localhost:5432;Database=postgres;");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ConsoleApp1.data.model;
|
||||
[Table("ability")]
|
||||
[Index(nameof(Name), IsUnique = true) ]
|
||||
public class Ability
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("ability_id")]
|
||||
public int Id { get; set; }
|
||||
[Column("ability_name")]
|
||||
public string Name { get; set; }
|
||||
[Column("ability_short_effect")]
|
||||
public string ShortEffect { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
|
||||
namespace ConsoleApp1.data.model;
|
||||
[Table(name:"pokemon")]
|
||||
[Index (nameof(name), IsUnique = true)]
|
||||
public class Pokemon
|
||||
|
||||
{
|
||||
[Key]
|
||||
[Column(name:"pokemon_id")]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int id { get; set; }
|
||||
[Column("pokemon_name")]
|
||||
[Required]
|
||||
[MaxLength(30)]
|
||||
public string name { get; set; }
|
||||
|
||||
[Column("pokemon_height_m")]
|
||||
[Required]
|
||||
public double height { get; set; }
|
||||
[Column("pokemon_weight_kg")]
|
||||
[Required]
|
||||
public double weight { get; set; }
|
||||
[Column("pokemon_base_experience")]
|
||||
[Required]
|
||||
public double base_experience { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ConsoleApp1.data.model;
|
||||
[Table("PokemonAbilities")]
|
||||
[PrimaryKey(nameof(idAbility), nameof(PokemonId))]
|
||||
public class PokemonAbility
|
||||
{
|
||||
[Column("pokemon_id")]
|
||||
public int PokemonId { get; set; }
|
||||
[Column("ability_id")]
|
||||
public int idAbility { get; set; }
|
||||
[Column("pokemon_ability_is_hidden")]
|
||||
public Boolean abilityHidden { get; set; }
|
||||
|
||||
[ForeignKey(nameof(idAbility))]
|
||||
public virtual Ability Ability { get; set; }
|
||||
|
||||
[ForeignKey(nameof(PokemonId))]
|
||||
public virtual Pokemon Pokemon { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ConsoleApp1.data.model;
|
||||
[Table("PokemonStats")]
|
||||
[PrimaryKey(nameof(IdStat), nameof(PokemonId))]
|
||||
public class PokemonStat
|
||||
{
|
||||
[Column("stat_id")]
|
||||
public int IdStat { get; set; }
|
||||
[Column("pokemon_id")]
|
||||
public int PokemonId { get; set; }
|
||||
[Column("pokemon_stat_base_stat")]
|
||||
public string statBase { get; set; }
|
||||
|
||||
[ForeignKey(nameof(IdStat))]
|
||||
public virtual Stat Stat { get; set; }
|
||||
[ForeignKey(nameof(PokemonId))]
|
||||
public virtual Pokemon Pokemon { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ConsoleApp1.data.model;
|
||||
|
||||
[Table("pokemon_type")]
|
||||
[PrimaryKey(nameof(TypeId), nameof(PokemonId))]
|
||||
public class PokemonType
|
||||
{
|
||||
[Column("pokemon_id")]
|
||||
public int PokemonId { get; set; }
|
||||
|
||||
[Column("type_id")]
|
||||
public int TypeId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("pokemon_type_slot")]
|
||||
public int Slot { get; set; }
|
||||
|
||||
[ForeignKey(nameof(TypeId))]
|
||||
public virtual Type Type { get; set; }
|
||||
|
||||
[ForeignKey(nameof(PokemonId))]
|
||||
public virtual Pokemon Pokemon { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ConsoleApp1.data.model;
|
||||
|
||||
[Table("stat")]
|
||||
[Index (nameof(Name), IsUnique = true)]
|
||||
public class Stat
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("stat_id")]
|
||||
public int Id { get; set; }
|
||||
[Column("name")]
|
||||
public string Name { get; set; }
|
||||
[Column("pokemon_HP")]
|
||||
public int HP { get; set; }
|
||||
[Column("pokemon_Attack")]
|
||||
public int Attack { get; set; }
|
||||
[Column("pokemon_Defense")]
|
||||
public int Defense { get; set; }
|
||||
[Column("pokemon_SpecialAttack")]
|
||||
public int SpecialAttack { get; set; }
|
||||
[Column("pokemon_SpecialDefense")]
|
||||
public int SpecialDefense { get; set; }
|
||||
[Column("pokemon_Speed")]
|
||||
public int Speed { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ConsoleApp1.data.model;
|
||||
[Table("type")]
|
||||
[Index (nameof(Name), IsUnique = true)]
|
||||
public class Type
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column(name:"type_id")]
|
||||
public int typeId { get; set; }
|
||||
[Column(name:"type_name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user