Monsieur Wholesome
Monsieur Wholesome
CC#
Created by Cpt. Reis on 12/4/2024 in #help
Proper usage of EF Core in teams?
As long as you have a policy that enforces PRs, and disallows pushing to dev/develop/main directly, it should be managable, even with the newbies 😄
8 replies
CC#
Created by Cpt. Reis on 12/4/2024 in #help
Proper usage of EF Core in teams?
The re-doing of the migration with rebasing ain't that bad tbh, unless you have a really really big database project. Because Remove-Migration & Add-Migration will force rebuild the project before doing the Migration generation magic. Of course, you can force it to not rebuild via a --no-rebuild flag or something, but the default is to let it build the latest version of your code We have a pretty sizable database project, and when compiling only the Database with no migrations, it takes around 16 seconds One pain point however of managing EFC Migrations: Each migration creates and keeps a .Designer.cs which is a snapshot of the entire database, and each migration adds onto the last Snapshot, so it gets bigger and bigger. So after like 30 Migrations it causes our Database project file to bloat up to 1:30 Minutes in compile time. Which is pretty annoying. Not just that, but it hogs up huge amounts of RAM during compilation just because it needs to compile essentially the same huge file again and again. There is currently no solution to that, and it's only a problem if you've got a huuge database project. The only workaround is to squash the Migrations. basically eliminating the option to rollback to previous migrations and merging all 30+ Migrations into 1 initial.cs migration. It's a process that we are planning on implementing regularly at some point, and as far as I have heard, other companies do that too
8 replies
CC#
Created by Cpt. Reis on 12/4/2024 in #help
Proper usage of EF Core in teams?
@Cpt. Reis
8 replies
CC#
Created by Cpt. Reis on 12/4/2024 in #help
Proper usage of EF Core in teams?
One thing however is You can leave out applying migrations, as long as the migrations were added in incremental order - 20241201_AddTableX.cs -- Added 01st December - 20241202_CriticalChangeY.cs -- Added 02nd December - 20241203_UpdateColumnZ.cs -- Added 03rd December All of these were Add-Migration'ed one after the other, nicely, but you still need CriticalChangeY for testing, and you cannot afford it to go live on the prod update tomorrow Then you can simply leave out the commit which added that Migration, via a hotfix / release branch with cherry picking, so that its "Up()" method can never run. And yes, if you later on add CriticalChangeY back onto your deployed branch, it will work with no problems We do that sometimes 😉
8 replies
CC#
Created by Cpt. Reis on 12/4/2024 in #help
Proper usage of EF Core in teams?
EFC Migrations are always supposed to be added in incremental order Never never never let two migrations be made and merged in parallel. They need to be added one after the other If two people work on the DB within two PRs, then the PR who is getting merged second has to bite the bullet, and needs to - Rollback the Migration from their local db (Update-Database to previous migration) - Undo the Migration (Revert XContextModelSnapshot.cs, Delete 20241204.....MigrationName.cs & 20241204.....MigrationName.Design.cs) - Rebase PR branch to the develop / main branch with the other migration - Add-Migration now that we have the other migration - Push / Update PR
8 replies
CC#
Created by Protagonist on 11/7/2024 in #help
Console Doesn't Clear and Provides nested outputs
Old output being overwritten with new output
102 replies
CC#
Created by Protagonist on 11/7/2024 in #help
Console Doesn't Clear and Provides nested outputs
It kinda looks like old output? Like a Windows Terminal Buffering error
102 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
Thaat is up to you to fix now
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
A good database design will teach you a thing or two about good practice :catlaugh:
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
Of course, you can scatter information about the existence of a file around the table, but it can and will in the long run hurt integrity Things will get lost, files will be deleted, and various tables need to be updated extensively
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
With a separate table for files, you'd have a centralized management point
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
The file class i gave as an example of what the table would probably look like
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
yes
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
In the db you change the column from byte[] type you were storing it as To an int Foreign Key, that points to a File object
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
public class File
{
public int Id { get; set; }
public string Name { get; set; }
public string Location { get; set; }
public ulong Size { get; set; }
}

public class FileManager
{
public File CreateFile(byte[] fileData, string fileName)
{
const string FileDirectory = "./Files";

var file = new File()
{
Name = fileName,
Size = fileData.Length,
Location = Path.Combine(FileDirectory, fileName)
};

File.WriteAllBytes(file, fileData);

// Save File to your sql database, which only contains an id, the name, maybe the file size and the Location of your file ("./Files/YourFileName.txt")
// You can then reference the File within whatever other database row you have via its id
SaveFileToDatabase(file);

return file;
}
}
public class File
{
public int Id { get; set; }
public string Name { get; set; }
public string Location { get; set; }
public ulong Size { get; set; }
}

public class FileManager
{
public File CreateFile(byte[] fileData, string fileName)
{
const string FileDirectory = "./Files";

var file = new File()
{
Name = fileName,
Size = fileData.Length,
Location = Path.Combine(FileDirectory, fileName)
};

File.WriteAllBytes(file, fileData);

// Save File to your sql database, which only contains an id, the name, maybe the file size and the Location of your file ("./Files/YourFileName.txt")
// You can then reference the File within whatever other database row you have via its id
SaveFileToDatabase(file);

return file;
}
}
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
And relational databases are very very expensive to host So it's just not a good practice
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
Huge amounts of data (images, arbitrary binary data, big amounts of texts, etc etc) make databases slow
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
I approve of what Z said
61 replies
CC#
Created by ZML on 7/12/2024 in #help
Handling Nullable Property Updates in ASP.NET
The requester has to send the value
7 replies