linq2db / linq2db

Linq to database provider.
MIT License
2.99k stars 457 forks source link

CLI Tools - CodeAttribute ambiguous reference error #4384

Open croban opened 9 months ago

croban commented 9 months ago

My Problem

When attempting to add attributes, such as RequiredAttribute, using CodeAttributes, an ambiguous reference error is encountered in the generated class. This issue arises specifically when using the following line of code:

col.Property.CustomAttributes.Add(new CodeAttribute(typeParser.Parse<RequiredAttribute>()));

Encountered Error

The error message received is as follows:

Error CS0104: 'DataType' is an ambiguous reference between 'System.ComponentModel.DataAnnotations.DataType' and 'LinqToDB.DataType'

Current Limitation

As of now, there doesn't appear to be a straightforward method to specify attributes using their fully qualified namespace within the CodeAttributes addition. This limitation poses a challenge in resolving the ambiguous reference.

MaceWindu commented 3 months ago

conflicts option were designed to solve issues like that, but looks like it doesn't work well