To validate entries of a specific table, but mainly to reduce number of entries, I thought about let EF generate custom IDs for this specific table, as follows:
class TrainingTimeDefinition
{
public string Id { get; set; } // automatically generated: [this.WeekDay] + [this.StartTime] + [this.Period]
public DayOfWeek WeekDay { get; set; }
public TimeOnly StartTime { get; set; }
private TimeSpan Period { get; set; }
}
But it seems not to be as easy to implement in .NET core as with Jakarta/JPA. In my example above I left separators between WeekDays and e.g. StartTime, this just to reduce magnitude of my questions - as I saw that event this detail let programmers struggle and therefore ask questions in StackOverflow.
So about how to implement I found this: https://github.com/dotnet/efcore/issues/5303 and Can I store enums as strings in EF 5?
Relating to the second link: To make my questions easier, please don't consider if WeekDay might be "Monday" or "1". For the purpose of this thread it does not matter.
- Is it really such an effort to get it done, so it is better to avoid solving it via EF? In other words: Do I ask the right question?
- I am new with EF. Is there a easier way to achieve it, letting EF create custom string-IDs like this?