Seeding failing when creating new product
https://github.com/ardalis/CleanArchitecture/blob/5770078450386b47be40f31ca10ee9cb8dd61353/MinimalClean/src/MinimalClean.Architecture.Web/Domain/ProductAggregate/Product.cs#L12
This logic needs to be inverted to id != ProductId.New as predicate is checked inside InvalidInput this way if (!predicate(input)). Because of this seeding is failing when running minimal version for this template and seeding database:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.ArgumentException: Use Product.Create() to create new products instead of passing ProductId.New to the constructor. (Parameter 'id')
Also there is a problem with Product creation, as it is using this: return new Product(ProductId.New, name, unitPrice);
So after the changes it won't be able to create new ones
Good catch, thanks. I should have tests for these. Also typically I would make the constructor private to force the use of Create; trying to recall why I didn't do so in this case.
I've been running into issues in a project similar to this one with Postgres and int identity columns. The use of Vogen was causing problems with the EF tracking as EF only wanted to generate the id for the identity columns if it was not set, but Vogen doesn't let you "not set" an instance. In that project I ended up just switching to guid keys because they worked better anyway but I need to resolve the general problem for identity columns.