I have database structure with one to many relationship, and need to declare string field as primary key. But EF creates the foreign key property 'Property name' in shadow state. As a result I get other Property name1 column.
Database entities:
public class Account
{
public int Id { get; set; }
public string AccountName { get; set; }
public List<Contact> Contacts { get; set; } = new();
public string IncidentName { get; set; }
public Incident Incident { get; set; }
}
public class Incident
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public string IncidentName { get; set; }
public List<Account> Accounts { get; set; }
}
Message:
The foreign key property 'Account.IncidentName1' was created in shadow state because a conflicting property with the simple name 'IncidentName' exists in the entity type, but is either not mapped, is already used for another relationship, or is incompatible with the associated primary key type.
How could I fix that?