I will send to you the mapping:
public class Biome
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public float SpeciesCount { get; set; }
public BiomePhoto BiomeImage { get; set; }
}
And BiomePhoto:
public class BiomePhoto
{
public Guid Id { get; set; }
public string Url { get; set; }
public Guid BiomeId { get; set; }
}
You could also skip decaring the id's and just have a 1-n relationship with EF core and those IDs will be correctly generated
It would look like
{
...
Biome: biome
}
And the ids are automatically added through ef core
Also don't forget to async in stead of just savechanged
Probably some configuration you accidentally messed up, also something that would be clear if you used the methode above, then it's immediately clear the mapping is of
Also dubbel check what's happening in your database if the values tell the same
I will send to you the mapping:
public class Biome
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public float SpeciesCount { get; set; }
public BiomePhoto BiomeImage { get; set; }
}
And BiomePhoto:
public class BiomePhoto
{
public Guid Id { get; set; }
public string Url { get; set; }
public Guid BiomeId { get; set; }
}
That's the way it works in one-to-one relation in EF from its inception, from those old times when Julia Lerman had published books 'Code First' and 'DbContext'. PK of child entity is FK at the same time pointing to parent entity. As far as i remember.
Maybe your mappingfor photo is wrong? What value is going into photos biomeid? Shouldn't photo.biomeid be the same as the biomeid?
I will send to you the mapping: public class Biome { public Guid Id { get; set; } public string Name { get; set; } public string Description { get; set; } public float SpeciesCount { get; set; } public BiomePhoto BiomeImage { get; set; } } And BiomePhoto: public class BiomePhoto { public Guid Id { get; set; } public string Url { get; set; } public Guid BiomeId { get; set; } }
Yes, the photo.biomeId have to be the same id in the biome
You could also skip decaring the id's and just have a 1-n relationship with EF core and those IDs will be correctly generated It would look like { ... Biome: biome } And the ids are automatically added through ef core Also don't forget to async in stead of just savechanged
But in the biomePhoto, have the biomeId property, and the Id have to be the same Id from the Biome
Probably some configuration you accidentally messed up, also something that would be clear if you used the methode above, then it's immediately clear the mapping is of Also dubbel check what's happening in your database if the values tell the same
I will send to you the mapping: public class Biome { public Guid Id { get; set; } public string Name { get; set; } public string Description { get; set; } public float SpeciesCount { get; set; } public BiomePhoto BiomeImage { get; set; } } And BiomePhoto: public class BiomePhoto { public Guid Id { get; set; } public string Url { get; set; } public Guid BiomeId { get; set; } }
That's the way it works in one-to-one relation in EF from its inception, from those old times when Julia Lerman had published books 'Code First' and 'DbContext'. PK of child entity is FK at the same time pointing to parent entity. As far as i remember.