hippiewho
.NET Core OnModelCreating gives me error
The error is because you are seeding data with
Guid.NewGuid()
. This means that when OnModelCreate
runs the guid will be different every time (i believe a similar issue can happen when using DateTime.Now).
If this is an existing code base (or if too lazy - if its a personal project) then you can simply suppress the error and fix later. If possible though you should change the seed data to use an explicit non changing GUID.26 replies
❔ Compare Enum Values with submitted value
Actually you got me thinking and so i just tested this out. I was wrong, you would need to make the values of the enum into powers of 2. By default enums are start at 0 get assigned a value +1 greater than the previous. Has flag only works correctly if the values are non zero and power of two. The flags attribute can enforce that rule but HasFlag is part of the enum type and can be used (incorrectly) when the enum is not power of 2
75 replies
❔ Compare Enum Values with submitted value
The has flag works rgardless because at its core its a bitwise check (IIRC). The flags attribute markes the enum as a powers of 2 flag (under the hood it uses binary flags - 0001, 0010, 0100, 1000, etc)
75 replies