Adding Models for EntityFrameWork
This commit is contained in:
parent
3f31133b3b
commit
35e8dc8188
@ -7,10 +7,15 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MySql.Data.EntityFramework" Version="8.0.21" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0-preview.7.20365.15" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0-preview.7.20365.15" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.0-preview.7.20365.15" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0-preview.7.20365.15" />
|
||||
<PackageReference Include="nunit" Version="3.12.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.2" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql.Design" Version="1.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -9,11 +9,16 @@
|
||||
<PackageReference Include="DiceRoller" Version="4.1.0" />
|
||||
<PackageReference Include="Discord.Net" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="3.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0-preview.7.20365.15" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0-preview.7.20365.15" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.0-preview.7.20365.15" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0-preview.7.20365.15" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
|
||||
<PackageReference Include="MySql.Data.EntityFramework" Version="8.0.21" />
|
||||
<PackageReference Include="NLog" Version="4.7.2" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="1.6.4" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.2" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql.Design" Version="1.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -22,4 +27,8 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Models" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
15
ChaosBot/Models/LodestoneCharacter.cs
Normal file
15
ChaosBot/Models/LodestoneCharacter.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ChaosBot.Models
|
||||
{
|
||||
public partial class LodestoneCharacter
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Avatar { get; set; }
|
||||
public long? UserId { get; set; }
|
||||
}
|
||||
}
|
||||
13
ChaosBot/Models/LodestoneFreeCompany.cs
Normal file
13
ChaosBot/Models/LodestoneFreeCompany.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ChaosBot.Models
|
||||
{
|
||||
public partial class LodestoneFreeCompany
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
15
ChaosBot/Models/PointsTable.cs
Normal file
15
ChaosBot/Models/PointsTable.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ChaosBot.Models
|
||||
{
|
||||
public partial class PointsTable
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? Points { get; set; }
|
||||
public long? UserId { get; set; }
|
||||
public long? GuildId { get; set; }
|
||||
}
|
||||
}
|
||||
14
ChaosBot/Models/RaffleTable.cs
Normal file
14
ChaosBot/Models/RaffleTable.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ChaosBot.Models
|
||||
{
|
||||
public partial class RaffleTable
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public long? UserId { get; set; }
|
||||
public long? GuildId { get; set; }
|
||||
}
|
||||
}
|
||||
14
ChaosBot/Models/ServerConfigurationFlag.cs
Normal file
14
ChaosBot/Models/ServerConfigurationFlag.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ChaosBot.Models
|
||||
{
|
||||
public partial class ServerConfigurationFlag
|
||||
{
|
||||
public string Key { get; set; }
|
||||
public string SerializedValue { get; set; }
|
||||
public long? GuildId { get; set; }
|
||||
}
|
||||
}
|
||||
167
ChaosBot/Models/chaosbotContext.cs
Normal file
167
ChaosBot/Models/chaosbotContext.cs
Normal file
@ -0,0 +1,167 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ChaosBot.Models
|
||||
{
|
||||
public partial class chaosbotContext : DbContext
|
||||
{
|
||||
public chaosbotContext()
|
||||
{
|
||||
}
|
||||
|
||||
public chaosbotContext(DbContextOptions<chaosbotContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual DbSet<LodestoneCharacter> LodestoneCharacters { get; set; }
|
||||
public virtual DbSet<LodestoneFreeCompany> LodestoneFreeCompanies { get; set; }
|
||||
public virtual DbSet<PointsTable> PointsTables { get; set; }
|
||||
public virtual DbSet<RaffleTable> RaffleTables { get; set; }
|
||||
public virtual DbSet<ServerConfigurationFlag> ServerConfigurationFlags { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
|
||||
optionsBuilder.UseMySql($"server={Program.LoadConfiguration("Database:Host")};port={Program.LoadConfiguration("Database:Port")};user={Program.LoadConfiguration("Database:User")};password={Program.LoadConfiguration("Database:Pass")};database={Program.LoadConfiguration("Database:Name")}", x => x.ServerVersion("5.5.64-mariadb"));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<LodestoneCharacter>(entity =>
|
||||
{
|
||||
entity.HasNoKey();
|
||||
|
||||
entity.ToTable("LodestoneCharacter");
|
||||
|
||||
entity.Property(e => e.Avatar)
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("avatar")
|
||||
.HasCharSet("latin1")
|
||||
.HasCollation("latin1_swedish_ci")
|
||||
.HasAnnotation("Relational:ColumnType", "text");
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Relational:ColumnType", "int(11)");
|
||||
|
||||
entity.Property(e => e.Name)
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("name")
|
||||
.HasCharSet("latin1")
|
||||
.HasCollation("latin1_swedish_ci")
|
||||
.HasAnnotation("Relational:ColumnType", "text");
|
||||
|
||||
entity.Property(e => e.UserId)
|
||||
.HasColumnType("bigint(20)")
|
||||
.HasColumnName("userId")
|
||||
.HasAnnotation("Relational:ColumnType", "bigint(20)");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<LodestoneFreeCompany>(entity =>
|
||||
{
|
||||
entity.HasNoKey();
|
||||
|
||||
entity.ToTable("LodestoneFreeCompany");
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("id")
|
||||
.HasCharSet("latin1")
|
||||
.HasCollation("latin1_swedish_ci")
|
||||
.HasAnnotation("Relational:ColumnType", "text");
|
||||
|
||||
entity.Property(e => e.Name)
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("name")
|
||||
.HasCharSet("latin1")
|
||||
.HasCollation("latin1_swedish_ci")
|
||||
.HasAnnotation("Relational:ColumnType", "text");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<PointsTable>(entity =>
|
||||
{
|
||||
entity.HasNoKey();
|
||||
|
||||
entity.ToTable("PointsTable");
|
||||
|
||||
entity.Property(e => e.GuildId)
|
||||
.HasColumnType("bigint(20)")
|
||||
.HasColumnName("guildId")
|
||||
.HasAnnotation("Relational:ColumnType", "bigint(20)");
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Relational:ColumnType", "int(11)");
|
||||
|
||||
entity.Property(e => e.Points)
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("points")
|
||||
.HasAnnotation("Relational:ColumnType", "int(11)");
|
||||
|
||||
entity.Property(e => e.UserId)
|
||||
.HasColumnType("bigint(20)")
|
||||
.HasColumnName("userId")
|
||||
.HasAnnotation("Relational:ColumnType", "bigint(20)");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<RaffleTable>(entity =>
|
||||
{
|
||||
entity.HasNoKey();
|
||||
|
||||
entity.ToTable("RaffleTable");
|
||||
|
||||
entity.Property(e => e.GuildId)
|
||||
.HasColumnType("bigint(20)")
|
||||
.HasColumnName("guildId")
|
||||
.HasAnnotation("Relational:ColumnType", "bigint(20)");
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.HasColumnType("int(11)")
|
||||
.HasColumnName("id")
|
||||
.HasAnnotation("Relational:ColumnType", "int(11)");
|
||||
|
||||
entity.Property(e => e.UserId)
|
||||
.HasColumnType("bigint(20)")
|
||||
.HasColumnName("userId")
|
||||
.HasAnnotation("Relational:ColumnType", "bigint(20)");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ServerConfigurationFlag>(entity =>
|
||||
{
|
||||
entity.HasNoKey();
|
||||
|
||||
entity.Property(e => e.GuildId)
|
||||
.HasColumnType("bigint(20)")
|
||||
.HasColumnName("guildId")
|
||||
.HasAnnotation("Relational:ColumnType", "bigint(20)");
|
||||
|
||||
entity.Property(e => e.Key)
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("key")
|
||||
.HasCharSet("latin1")
|
||||
.HasCollation("latin1_swedish_ci")
|
||||
.HasAnnotation("Relational:ColumnType", "text");
|
||||
|
||||
entity.Property(e => e.SerializedValue)
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("serializedValue")
|
||||
.HasCharSet("latin1")
|
||||
.HasCollation("latin1_swedish_ci")
|
||||
.HasAnnotation("Relational:ColumnType", "text");
|
||||
});
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
}
|
||||
|
||||
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user