You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class PARENT
{
public string ID_PARENT { get; set; }
public int? ID_PARENT_BIS { get; set; }
public List<CHILD> CHILDREN { get; set; }
}
This table has a primary key : ID_PARENT. The ID_PARENT_BIS is used into several relationships.
public class CHILD
{
[Required]
public string PID_CHILD { get; set; }
public int ID { get; set; }
public int? ID_PARENT_BIS { get; set; }
[Required]
public string ID_EXTCHILD { get; set; }
}
Between both, there are a relationships many to one. Here is the mapping :
The mapping is correct but when I want to retrieve all elements of PARENT, I have the following error :
An unhandled exception occurred while processing the request. InvalidCastException: La colonne contient des données NULL (Column contain null data)
My relation need to be configured to work with ID_PARENT_BIS, not ID_PARENT. Because ID_PARENT_BIS could be null in database. This is a prerequisites of the project.
So is it really possible to do that with entity framework core ?
Thanks !
The text was updated successfully, but these errors were encountered:
@stynn To clarify, ID_PARENT_BIS is a nullable column in the database, but you want to use this as an alternate key for the principal end of the relationship? if so, this is a duplicate of issue #4415
@ajcvickers In fact, ID_PARENT_BIS is a nullable column in database and I want to use it into a relation many to one. If the PARENT table has no CHILD, the ID_PARENT_BIS is null in my database. There is a way to map this in EF Core ?
@stynn I'm not sure I am following completely. Can you post some examples of different combinations of nulls and keys database rows and describe how they should map to the properties of your objects?
EF Team Triage: Closing this issue as the requested additional details have not been provided and we have been unable to reproduce it.
BTW this is a canned response and may have info or details that do not directly apply to this particular issue. While we'd like to spend the time to uniquely address every incoming issue, we get a lot traffic on the EF projects and that is not practical. To ensure we maximize the time we have to work on fixing bugs, implementing new features, etc. we use canned responses for common triage decisions.
I have two tables in my database :
This table has a primary key :
ID_PARENT
. TheID_PARENT_BIS
is used into several relationships.Between both, there are a relationships many to one. Here is the mapping :
The mapping is correct but when I want to retrieve all elements of PARENT, I have the following error :
My relation need to be configured to work with
ID_PARENT_BIS
, notID_PARENT
. BecauseID_PARENT_BIS
could be null in database. This is a prerequisites of the project.So is it really possible to do that with entity framework core ?
Thanks !
The text was updated successfully, but these errors were encountered: