populus
✅ ForeignKey Entity Framework and Identity
I was hoping I could declare a List<Guid> and have the DB populate it with every associated AccountId one-by-one as they become relevant.
"it is the POST that needs a FK..." - My attempt at this was to create these List<Guid>.
What is your recommended course of action?
24 replies
❔ View cannot be found.
I am on the final stretches of my C# programming course and I guess MVC was what we learned. I don't know how I got Razor pages in the mix, but I think MVC is the way to go for me.
But let's suppose I did want to do the Razor Pages code way, isn't it essentially just moving the code in there?
I am using Aspnet.core.Identity and entityframeworkcore for Auth and DB respectively.
23 replies
❔ View cannot be found.
I did not realize these were different frameworks.
But it seems like using controllers and .cshtml files with the "@page" directive works? Because that's how I got it to work partially during my work on this.
You would recommend me to troubleshoot this on google by using "MVC" as part of the keyword(s) searched?
23 replies
❔ View cannot be found.
Hey, so /Pages/ was the default folder added by the scaffolding. I tried creating a /Views/ folder and moving the relevant files there but I ran into some 405 issues so I assumed /Pages/ was the correct way.
I can't quite puzzle it together.
23 replies
❔ Entity Framework - SqlException
So what you're saying is that 'MSSQLLocalDB' is not a built-in variable but a customizable one to what I set it?
The thing is though that I am seeing the databases from my other project(s) in the Server Object Explorer. I don't know any other lines or places where I have written 'MSSQLLocalDB' so that's why I assumed it was like saying "Use this protocol".
After deleting the 'Migrations' folder and running ' dotnet ef migrations add InitialCreate ' followed up with 'dotnet ef database update' and re-building the project I notice that I don't get the configuration log in the console, suggesting that the database update isn't happening at even that stage. Even though I get a new 'Migrations' folder.
15 replies
❔ Entity Framework - SqlException
Thanks, I was pretty sure I remembered everything needed to get going with this database but there is just something minor I am overlooking here somewhere.
The page you linked seems to be talking about a relevant but at the same time irrelevant branch of what I'm doing. I say that because I haven't read about LocalDB specifically before and I have succeeded in creating a database with Entity Framework Core and Microsoft SQL DB previously.
I did start this VS project as a console app and I am wondering whether or not that means some pre-requisites aren't configured, for example 'builder.services' which I haven't fully grasped the functionality of yet.
If that is the case please let me know.
Am working on reading through old lecture PDF's but for now this thread is still in need of input.
15 replies
❔ Entity Framework - SqlException
You would have to clarify for me what a database instance is.
The line you're referring to is copied from a functional database setup on the same PC and environment.
I think it means Microsoft SQL Local DB and should correspond to the packages included with the NuGet install of Entity Framework Core and the related packages.
15 replies
❔ Entity Framework - SqlException
Yes, same error but a little different. I am using Entity Framework core 7.0.1. In SQL Server Object Explorer the database does not show up so it's not getting created in the first place.
But to my understanding it is supposed to get created automatically by the code I have provided, no?
This is the first time I'm attempting to create a EF database aside from the time(s) we did it in school.
15 replies