morry329#
Id points to always null
I have an Edit method which always returns a null id: https://pastecode.io/s/upokmghg
I tried to map the Id (from the controller/model) on my cshtml but it did not help. Could anyone kindly point me in the right direction??
7 replies
InvalidCastException: Unable to cast object of type
The full exception reads
InvalidCastException: Unable to cast object of type 'Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable1[WebApplication1.Models.ListingProjectsDTO]' to type 'System.String'.
The exception points at this method
`
I am not good at casting at all, I have tried return (System.string) obj. I tried to create a list with System.string data type with the help of foreach in the TestDashboard1(). Those of course failed.
Could anyone kindly point me in the right direction?
PS: if anyone is wondering why I am using the generic method here, see https://stackoverflow.com/questions/870697/unable-to-cast-object-of-type-system-dbnull-to-type-system-string3 replies
✅ NullPointException in the Update/Post method, but not in the Get Method
I started feeling puzzled at this NullPointException in this code
`
In the Get method it grabs the id but the following Post method it does not and crashes into NullPointException. Seems to me like the GET method was able to refer to the row existing in my DB. However that does not seem to be the case for the Post method.
Could anyone help me understand why?
My code: https://pastebin.com/pXHYHfKM
46 replies
Unable to create an object of type 'JsonContext'
I have fought this error for about an hour and finally gave up - would like a second set of eyes.
I wanted to use
dotnet ef migrations add InitialCreate
which prompted this error
Could you kindly point me in the right direction?
https://pastebin.com/GuxUApaW8 replies
✅ System.InvalidOperationException: No database provide has been configured for this DbContext
It is all about this newbie error
I have no clue what triggered all this. Could kindly point me in the right direction?
https://pastebin.com/RbkExv6j This is full code and full exception message for your reference.
7 replies
Edit view directs to 404 not found
A beginner's mistake - the problem is that i have been getting Site Not Found 404 error (as per screenshot) while I wanted to display the edit dashboard view on localhost:https://imgur.com/a/mw5wBkD
i think the connection between my view (html and js) and controller has gone wrong: https://pastebin.com/n4cfnwLp
Could anyone kindly point out what I have been missing out here?
6 replies
Edit function does not work
So I would like a second set of eyes. I wanted to try editing the pre-existing record on my card view (see the screenshot attached) like Beachfront Villa -> Beachfront Villa 8. Even this easy modification does not succeed, as on clicking the save button I got "record not found"
And this comes from here in the controller
and this is what the frontend devtool says: https://imgur.com/a/xs8LLlD
my database has not the id "1" referred in that devtool:
`
my save button on View should have been picking up any ids listed here (5,6, or 74) but as the devtool shows it picks up 1 instead. i suppose if it picks up 5,6,74 it will let me edit the ListingName property.
so could anyone kindly point me in the right direction? Relevant code snippets here https://pastebin.com/9U9zjvaG
20 replies
✅ always gets the invalid data received
I have been creating a simple CRUD app with the ASP.NET. My update function does not work as expected: the save button triggers the error message "invalid data received" ; somehow the model reference is considred null on clicking the save button
could anyone kindly advice me on why the save button does not save the user input as expected? the full code here https://pastebin.com/4C2aYF78
2 replies
Insert Method does not insert or save the user input as wanted
I have a working UI with a text field to enter a property name like "Ca* Oro Bridge" on my MVC view. The save button is also displayed on the view. Onclick it does not save the userinput in the text field (henceforth it is also not saved in the DB). I have debugged the follwing code responsible for handling user inputs
`
I am not versed in the world of debugging, but it looks like the HttpGet method refers or returns null. InsertListing method (HttpPost method) deems it as !ModelState.Isvalid (which means my code does not save the input at all)
Now I don't quite understand what caused all this null and invalidity. https://pastebin.com/DhCg4Md2
Can anyone kindly point me in the right direction?
1 replies
Does it make sense to two references (to database migration and data seeding) in the same using
I am totally new to this, so I rely on chatGPT a lot
With the help of GPT I have wrote a code like this
As you see this is the Program.cs snippet (ASP.NET Core 7). My concern is that this code might make no sense to have db.Database.Migrate(); and seeder.SeedModels(); under the same roof (the same
What do you all think of this snippet?
using
). I don't know much about all this ASP.NET world but I migrated database a couple of times via the commandline like dotnet ef add-migration
etc. so I started wondering if db.Database.Migrate();
in Program.cs makes any sense.What do you all think of this snippet?
6 replies
MySqlException: Column 'Age' cannot be null
So this error occured in the following scenario: I have created a simple ASP.NET Core web app with some simple db configurations. On running dotnet run from Rider, the browser displayed my web app (a login form). I have click "register a new user". Then I was redirected to a register form page with three textfields , email, password and repeat password. I filled in all of them and hit register. Now I was bugged with this bunch of exception texts https://pastebin.com/7DqbUai5
I don't understand this error Column 'Age' cannot be null. I made extra sure that my DB has the column Age with non-null values like this:
`
For your reference this is the link to the codes https://pastebin.com/k88fKn7r
Could anyone point me in the right direction?
I want to solve this error but I need another set of eyes
PS: I am just thinking that this error may refer to the column Age which belongs to another table from another DB. The output displayed here came from the table PortalUser in the searchhome DB, but I may have another PortalUser table in my second DB. If that is the case will this error point to that another PortalUser which may have no column values? Hope all this makes sense.
7 replies