generated from admin/template
начал
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace PokedexApi.Data.Models;
|
||||
[Table("ability")]
|
||||
[Index(nameof(Name), IsUnique = true)]
|
||||
public class Ability
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("ability_id")]
|
||||
public int AbilityId { get; set; }
|
||||
[Column("ability_name")]
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string Name { get; set; }
|
||||
[Column("ability_description")]
|
||||
[Required]
|
||||
public string Description { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace PokedexApi.Data.Models;
|
||||
[Table("pokemon")]
|
||||
[Index(nameof(Name), IsUnique = true)]
|
||||
public class Pokemon
|
||||
{
|
||||
[Key]
|
||||
[Column("pokemon_id")]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
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; }
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace PokedexApi.Data.Models;
|
||||
[Table("pokemonAbility")]
|
||||
[Index(nameof(Name), IsUnique = true)]
|
||||
public class PokemonAbility
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("pokemon_ability_id")]
|
||||
public int AbilityId { get; set; }
|
||||
[Column("pokemon_ability_name")]
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
[Column("IsHidden")]
|
||||
[Required]
|
||||
public bool IsHidden { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace PokedexApi.Data.Models;
|
||||
[Table("type")]
|
||||
[Index(nameof(Name), IsUnique = true)]
|
||||
public class Type
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("type_id")]
|
||||
public int TypeId { get; set; }
|
||||
[Column("type_name")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PokedexApi.Data.Models;
|
||||
using Type = PokedexApi.Data.Models.Type;
|
||||
|
||||
namespace PokedexApi.Data;
|
||||
|
||||
public class PokemonContext: DbContext
|
||||
{
|
||||
public DbSet<Type> Types { get; set; }
|
||||
public DbSet<Pokemon> Pokemons { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
optionsBuilder.UseNpgsql("Username=postgres;Password=123;Host=localhost:5432;Database=postgres");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user