Greetings,we are trying with no success to put data annotations for the model used by a SfGrid component in a metadata class.
If we put the annotations directly in the model class (as the [Required] annotation in the example below) it works like a charm:
public class MyModel
{
public int Id { get; set; }
[Required]
public string Description { get; set; }
}
The problem is that we are using Entity Framework and database-first approach, so we cannot put annotation directly in the model class, which is auto-generated.
We use a partial class and a metadata class, all in the same namespace of the auto-generated model class:
[MetadataType(typeof(MyModelMetadata))]
public partial class MyModel { }
public class MyModelMetadata
{
[Required]
public string Description { get; set; }
}
In this case the [Required] annotation is ignored by SfGrid.
Does Blazor SfGrid support data annotation in metadata class at all? The use of metadata classes is very common in database-first approach, so I'm wondering if there is any other way to solve the problem.
(In the forum there is a
similar thread, but it's about ASP.NET MVC, not Blazor.)