C
C#6mo ago
GodsAperture

.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");
}

}
}
1 Reply
GodsAperture
GodsApertureOP6mo ago
Never mind, I got my solution, I didn't realize how mapping between classes and tables worked, and that class names were automatically being mapped to table names. Good to know now :harold:
Want results from more Discord servers?
Add your server