Skip to content

Seeding failing when creating new product #987

@whyzlo

Description

@whyzlo

Guard.Against.InvalidInput(id, nameof(id), (id) => id == ProductId.New,

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions