Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Core 2.1 code generation error - Multiple custom attributes of the same type found

I have a DbContext that contains several DbSets of classes, with some of the classes have properties of class types that are not specifically defined in the DbContext. The migration and the Database update work smoothly. However, when I try to use the code generation tool I get the error:

Multiple custom attributes of the same type found.

First of all, I am not using any "Custom" attributes, only the following (and not on the same properties):

[ScaffoldColumn(true/false)]
[DataType(DataType.EmailAddress/PhoneNumber/Date/PostalCode/Password)]
[DisplayFormat]
[Required(ErrorMessage = "message.")]
[Phone(ErrorMessage = "A phone number is required")]
[DataType(DataType.PhoneNumber)]

I have too many lines of code to post here, but I can add some snippets if needed.

like image 676
JNickVA1 Avatar asked Sep 19 '25 13:09

JNickVA1


1 Answers

You have used DataType twice. Choose whether you have a DataType.EmailAddress/PhoneNumber/Date/PostalCode/Password or a DataType.PhoneNumber.

[DataType(DataType.EmailAddress/PhoneNumber/Date/PostalCode/Password)]
[DataType(DataType.PhoneNumber)]
like image 136
Fenton Avatar answered Sep 21 '25 02:09

Fenton