C
C#•2w ago
Lulers

Learning DB and Identity

Good afternoon friends, I have a CSC Bachelors however I never learned C# and am now picking the subject up to try and utilize my degree to become a backend C# dev. I am very passionate about it, and although I gained no experience after my graduation 4 years ago, I decided to change the course of my life and teach myself (With the help of one friend who is in the field) and gain the needed experience to become a full time backend C# dev. I am currently working on a practice project, backend system for a nutrition tracking / diet assistant web based app with ASP.NET. The reason I am making the post is I would like to get some guidance on what path I should take to learn the subjects of Microsoft SQL database and the Identity library to be implemented into my practice project. What I am thinking is to implement a database, and then after that is implemented, to learn Identity and adjust the DB to work together with it. The thing is however, I never implemented these before with C#, and I am curious if I am making a mistake implementing the first over the other. To save me hours of backtracking, what would you suggest to be the best approach for learning these subjects and to implement them into a project I will upload to my github?
13 Replies
Shazanman
Shazanman•2w ago
Best approach would be reading about in the Microsoft docs Start here for identity https://learn.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-8.0&tabs=visual-studio I assumed you are using asp.net
Introduction to Identity on ASP.NET Core
Use Identity with an ASP.NET Core app. Learn how to set password requirements (RequireDigit, RequiredLength, RequiredUniqueChars, and more).
Shazanman
Shazanman•2w ago
Correct me if I'm wrong Should be straightforward Comment here if you run into problems while following it People will come in to help out
Lulers
Lulers•2w ago
Oh turns out Identity has a built in DB functionality. That makes sense. I will read through it soon when I will be coding, and I assume after I implement Identity, I can adjust / change the DB to fit my needs
Shazanman
Shazanman•2w ago
yes it does
Pobiega
Pobiega•2w ago
specifically, Identity can use a very commonly used database library/ORM called EF Core they provide their own baseclass to use for your custom DbContext called IdentityDbContext<T> its perfectly fine to learn how to use EF without identity first, if you want to focus on that but its also fine to just dive in with both at the same time
Lulers
Lulers•2w ago
Thank you for your response, What I currently am trying to practice on is creating a DB model for a table called "UserProfile" to hold profile information that is important for backend functionality, but not for authentication or registration. As I understood using the documentation and some ChatGPT is that (and correct me if I am totally misunderstanding that) Identity will automatically create a bunch of tables, one of them being 'AspNetUsers' that will contain all the required fields for the library, and then I can manually edit my UserProfile table to connect the keys between them, as opposed to creating a custom UserInfo table and custom design it to fit the Identity library criteria. I am going to start working on it later after work tonight, so I still didnt get a chance to dive into it in practice and to get an understanding of what exactly I dont understand 🙂 And yeah, thats what I've started learning, Entity Framework Core
Pobiega
Pobiega•2w ago
Sort of You make your own user model that inherits and extends IdentityUser Then use that as your generic T in the context definition Boom, identity now stores your user info there And everything "just works"
Lulers
Lulers•2w ago
I see, so basically I would create that if I need to edit the generic user table identity would create, but if I will be fine with Identity's generic AspNetUsers and I would just use it's forein key to connect to my UserProfile table (which is not supposed to store any login information, it basically extends the user profile for other data like user age, weight, height etc) and leave it as is I guess, I think.
Pobiega
Pobiega•2w ago
That's one way, sure. Not sure I'd personally bother separating the two, but you can
Lulers
Lulers•2w ago
Having all of that data in one table would be conventionally safe? I.e the logic credentials, and other data to be used by the backend for nutrition tracking, BMI calculation etc? I was under the impression it would be safer to separate the two, but then again, ChatGPT told me so, and if I learned anything from Terminator, is not to rely on AI And thank you so much for the responses, this is super helpful!!!
Pobiega
Pobiega•2w ago
as long as they are in the same DB, I dont see how one is safer than the other I suppose I could see a point if a major part of your app is being able to gather info on your users, but you want to make sure you dont accidentally include username/password etc
Lulers
Lulers•2w ago
Yeah that makes sense. Weekly analytics, etc. I will look into that after the general DB items and Identity works. Thanks! I appreciate the help. I will be on it tonight
Pobiega
Pobiega•2w ago
np good luck 🙂
Want results from more Discord servers?
Add your server
More Posts
await-work in thread class is different from await-work in task class?var thread = new Thread(async () => { Console.WriteLine($"Thread before await: {Thread.CurrentThhow can i speed up this transparent image rendering in winforms?hello! i'll be frank; i found this code on Stack Overflow and it goes far over my head, i just need ✅ Access to the path 'C:\Users\Administarto\AppData\Local\Application Data' is deniedHello I want to create fivem cheat scanner and I added to source file location but I have this serro✅ How to get Options from DII configured options for google authentication `CliendId` and `ClientSecret`. ```csharp builder.SerLooking for more performant alternatives to reflection for iterating through properties of a classI've been using reflection to get the values of each of seventeen properties. I'm generating these vStopping Invoking the rest of the registered methods if the bool is trueAny possible ways to do it?hello can any one help me i have a problem on collisionThis post is for open discussion and questions. hello can any one help me i have a problem on colli✅ When I enter Visual Studio WPF, all lines of code in all scripts are underlined. How to fix this?I need to render text in my game with opentkI been trying to find a way to render text in opentk. I'm mainly looking for a way to render text anConverting null literal or possible null value to non-nullable type.Hey all real quick question, am still trying to learn c# and am getting a warning when using Console