© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
4 replies
engineertdog

Best way to model different options in EF Core

I have a class that's used to define the integration parameters for a particular process. Now, I have integration options A,B,C, etc each of which correspond to different tables with different IDs I need to populate on my class.

ex
public class myclass {
    public string MyParam1 { get; set; }
    public string MyParam2 { get; set; }
    public string MyParam3 { get; set; }

    // Integration A
    public Guid PackageId { get; set; }
    public Guid LocationId { get; set; }
    public Guid ScreenElementId { get; set; }
    // Integration B
    public Guid PackageId { get; set; }
    public Guid LocationId { get; set; }
    public Guid ScreenElementId { get; set; }
    // etc
}
public class myclass {
    public string MyParam1 { get; set; }
    public string MyParam2 { get; set; }
    public string MyParam3 { get; set; }

    // Integration A
    public Guid PackageId { get; set; }
    public Guid LocationId { get; set; }
    public Guid ScreenElementId { get; set; }
    // Integration B
    public Guid PackageId { get; set; }
    public Guid LocationId { get; set; }
    public Guid ScreenElementId { get; set; }
    // etc
}


Now, only 1 integration is supported for each instance of
myclass
myclass
. I could in theory define each available integration's FK references in this table, but there must be a better way to do this?

public class myclass {
    public string MyParam1 { get; set; }
    public string MyParam2 { get; set; }
    public string MyParam3 { get; set; }

    // Integration
    public IntegrationType Integration { get; set; } // A,B,C,etc
    public Guid IntegrationId { get; set; } // But wouldn't this just then be a table with all references, like in the previous example?
}
public class myclass {
    public string MyParam1 { get; set; }
    public string MyParam2 { get; set; }
    public string MyParam3 { get; set; }

    // Integration
    public IntegrationType Integration { get; set; } // A,B,C,etc
    public Guid IntegrationId { get; set; } // But wouldn't this just then be a table with all references, like in the previous example?
}
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

❔ Error adding new model in EF Core
C#CC# / help
3y ago
EF Core Model not-required property
C#CC# / help
4y ago
✅ Best practice with EF Core "constants"?
C#CC# / help
3y ago
EF Core
C#CC# / help
2y ago