© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
1 reply
Mariannnn

❔ EF Core Adding "1" to Column Name

Hello,

I got a problem while configuring a one-to-many relationship in .NET EF Core.
This is the parent class Coaches:
public class Coaches
{
public Guid CoachId { get; set; }
public virtual ICollection<License> License { get; set; }

public Coaches()
{
License = new HashSet<License>();
}

}

This is the second class License:
public class License
{

public Guid LicenseId { get; set; }
public Guid CoachId { get; set; }
public virtual Coaches Coach { get; set; }
}

Coaches entity builder configuration:
modelBuilder.Entity<Coaches>(entity =>
{
entity.HasKey(e => e.CoachId);
entity.Property(e => e.CoachId).ValueGeneratedNever();

entity.HasOne(p => p.Person)
.WithOne(p => p.Coach)
.HasForeignKey<Coaches>(p => p.PersonId)
.OnDelete(DeleteBehavior.Restrict)
.HasConstraintName("FK_Coaches_Person");
});

License entity builder configuration:
modelBuilder.Entity<License>(entity =>
{

entity.HasOne(d => d.Coach)
.WithMany(p => p.License)
.HasForeignKey(d => d.CoachId)
.OnDelete(DeleteBehavior.Restrict)
.HasConstraintName("FK_License_Coaches");

});

When I run this query: var license = await _context.License
.Where(c => c.LicenseId == command.LicenseId)
.FirstOrDefaultAsync(); -> I get the error: Invalid column name 'CoachId1'
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Adding EF Core Migration Error
C#CC# / help
4y ago
❔ Adding database entries with EF Core
C#CC# / help
3y ago
❔ EF Core 7 - FromSql join with same column names
C#CC# / help
3y ago
EF Core
C#CC# / help
2y ago