C#
C#

help

Root Question Message

LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
Scaffolding Error - Requires a primary key to be defined

Here's the class it's referring to
    public class ImageUris
    {
        [JsonPropertyName("small")]
        public string Small { get; set; }

        [JsonPropertyName("normal")]
        public string Normal { get; set; }

        [JsonPropertyName("large")]
        public string Large { get; set; }

        [JsonPropertyName("png")]
        public string Png { get; set; }

        [JsonPropertyName("art_crop")]
        public string ArtCrop { get; set; }

        [JsonPropertyName("border_crop")]
        public string BorderCrop { get; set; }
    }


I'll be honest I've read the key info in the error link and don't exactly understand what all of this means. I don't quite understand how keys work either.
FroH
FroH10/5/2022
Maybe you need one of those:
1. Property name ID
2. Add attribute called [Key] to one of your current property
3. Define your Key on ModelCreating
4. Tell EF that your entity doesn't have key using .HasNoKey()
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
Yeah I get that much, I guess I should ask what a key does.
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
I don't really understand this despite trying to read on the docs
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
so I have a Card { ImageUris ImageUris { get; set; } and then ImageUris { ... }
Message Not Public

Sign In and Join Server To See

10/5/2022
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
okie doke
Message Not Public

Sign In and Join Server To See

10/5/2022
Message Not Public

Sign In and Join Server To See

10/5/2022
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
yeah I'm just not understanding tbh
Message Not Public

Sign In and Join Server To See

10/5/2022
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
I mean I vaguely understand, but in practice of what I'm trying to do
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
vaguely, I've done a few tutorials
Message Not Public

Sign In and Join Server To See

10/5/2022
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
Can I just ask a couple dumb questions particular to what I'm doing? Or questions I imagine will help me understand? lol
Message Not Public

Sign In and Join Server To See

10/5/2022
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
What Could I use as a primary key for the imagesUris?
FroH
FroH10/5/2022
@@
Message Not Public

Sign In and Join Server To See

10/5/2022
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
the json doesn't serve an ID
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
for the images
FroH
FroH10/5/2022
u mean you don't want user to see your ID in Json?
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
again, I'm sorry lol. I am a brick.
Message Not Public

Sign In and Join Server To See

10/5/2022
Message Not Public

Sign In and Join Server To See

10/5/2022
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
No no, I just wholly don't understand this concept
Message Not Public

Sign In and Join Server To See

10/5/2022
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
from an api, I'm trying to make a magic the card game deck building app
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
figure that'd be a fun practical way to learn working SQL
Message Not Public

Sign In and Join Server To See

10/5/2022
Message Not Public

Sign In and Join Server To See

10/5/2022
Message Not Public

Sign In and Join Server To See

10/5/2022
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
So next question I guess. I can take any property in the ImageUris make it the PK, and the Card object will know to associate that specific set of ImageUris with it?
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
I get the idea, I just don't get how to use it
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
I just have to slap a PK on a property, and it'll keep track of which card references which images?
Message Not Public

Sign In and Join Server To See

10/5/2022
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
lol okay
Message Not Public

Sign In and Join Server To See

10/5/2022
Message Not Public

Sign In and Join Server To See

10/5/2022
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
the image urls will be unique so I figured that'd be good lol
Message Not Public

Sign In and Join Server To See

10/5/2022
Message Not Public

Sign In and Join Server To See

10/5/2022
Message Not Public

Sign In and Join Server To See

10/5/2022
Message Not Public

Sign In and Join Server To See

10/5/2022
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
I'm all ears bud. I'll google PRIMARY AUTO INCREMENT too when we're done
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
Yeah I haven't done annnything like that
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
only automated stuff
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
and some sql functions
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
in pgadmin / SSMS
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
I did see some stuff like that in docs so I'll take a second look.
LaPetiteMortDeSam
LaPetiteMortDeSam10/5/2022
I really didn't think it'd be this difficult lol. Every step of this programming journey has felt like climbing a mountain to find another mountain xD
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy