GodsAperture
GodsAperture
CC#
Created by GodsAperture on 7/3/2024 in #help
.Add() and .Update() aren't working, why though?
I am much newer to CRUD applications and here are my base classes:
C#
using System.Data.Common;
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations;

namespace RexLapis.Database{
//UserInfoClass represents the Discord user.
public partial class UserInfoClass{
[Key]
public string DiscordId { get; set; } = "";
public List<string> GenshinId { get; set; } = new List<string>();

public void Append(string input){
GenshinId.Append(input);
}
}

//GenshinIdClass represents a specific Genshin player account.
public partial class GenshinIdClass{
[Key]
public string GenshinId { get; set; } = "";
public string DiscordId { get; set; } = "";
public List<string> Characters { get; set; } = new List<string>();

public void Append(string input){
Characters.Append(input);
}
}
//
// Summary:
// DBClass represents the database I have, however the database itself will not
// be on GitHub.
public class DBClass : DbContext{

public virtual DbSet<UserInfoClass> UserInfo { get; set; }
public virtual DbSet<GenshinIdClass> GenshinInfo { get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder options)
{
options.UseSqlite("Data Source=UserInfo.db");
}

}
}
C#
using System.Data.Common;
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations;

namespace RexLapis.Database{
//UserInfoClass represents the Discord user.
public partial class UserInfoClass{
[Key]
public string DiscordId { get; set; } = "";
public List<string> GenshinId { get; set; } = new List<string>();

public void Append(string input){
GenshinId.Append(input);
}
}

//GenshinIdClass represents a specific Genshin player account.
public partial class GenshinIdClass{
[Key]
public string GenshinId { get; set; } = "";
public string DiscordId { get; set; } = "";
public List<string> Characters { get; set; } = new List<string>();

public void Append(string input){
Characters.Append(input);
}
}
//
// Summary:
// DBClass represents the database I have, however the database itself will not
// be on GitHub.
public class DBClass : DbContext{

public virtual DbSet<UserInfoClass> UserInfo { get; set; }
public virtual DbSet<GenshinIdClass> GenshinInfo { get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder options)
{
options.UseSqlite("Data Source=UserInfo.db");
}

}
}
2 replies