# Errors in models automatically generated from PostgreSQL

**URL:** <https://forum.radzen.com/t/errors-in-models-automatically-generated-from-postgresql/21316>\
**Category:** Radzen Blazor Studio\
**Created:** [January 27, 2026, 7:38am UTC](https://forum.radzen.com/t/errors-in-models-automatically-generated-from-postgresql/21316 "2026-01-27T07:38:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![robbiexgithub](https://forum.radzen.com/user_avatar/forum.radzen.com/robbiexgithub/32/16863_2.png) [@robbiexgithub](https://forum.radzen.com/u/robbiexgithub)\
**Post date:** [January 27, 2026, 7:38am UTC](https://forum.radzen.com/t/errors-in-models-automatically-generated-from-postgresql/21316/1 "2026-01-27T07:38:10Z")

</div>

**This error indicates that you have a `[MaxLength]`attribute applied to a field of type `char`in your model, but the `MaxLength`attribute can only be applied to string, array, or collection types.**

 ![2026-01-27 151210](https://forum.radzen.com/uploads/default/original/3X/4/2/4235fcbc3d877e22f1d34d596f2d9221c0713c36.png)

g HTTP request POST [http://localhost:5000/api/master-data/facility](http://localhost:5000/api/master-data/facility)  
[13:54:07 ERR] Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware - An unhandled exception has occurred while executing the request.  
System.InvalidCastException: The field of type System.Char must be a string, array or ICollection type.  
at System.ComponentModel.DataAnnotations.MaxLengthAttribute.IsValid(Object value)  
at System.ComponentModel.DataAnnotations.ValidationAttribute.IsValid(Object value, ValidationContext validationContext)  
at System.ComponentModel.DataAnnotations.ValidationAttribute.GetValidationResult(Object value, ValidationContext validationContext)  
at Microsoft.AspNetCore.Mvc.DataAnnotations.DataAnnotationsModelValidator.Validate(ModelValidationContext validationContext)  
at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.ValidateNode()  
at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.VisitImplementation(ModelMetadata& metadata, String& key, Object model)  
at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.Visit(ModelMetadata metadata, String key, Object model)  
at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.VisitChildren(IValidationStrategy strategy)  
at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.VisitComplexType(IValidationStrategy defaultStrategy)  
at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.VisitImplementation(ModelMetadata& metadata, String& key, Object model)  
at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.Visit(ModelMetadata metadata, String key, Object model)  
at Microsoft.AspNetCore.Mvc.ModelBinding.ObjectModelValidator.Validate(ActionContext actionContext, ValidationStateDictionary validationState, String prefix, Object model, ModelMetadata metadata, Object container)  
at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.EnforceBindRequiredAndValidate(ObjectModelValidator baseObjectValidator, ActionContext actionContext, ParameterDescriptor parameter, ModelMetadata metadata, ModelBindingContext modelBindingContext, ModelBindingResult modelBindingResult, Object container)  
at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, Object value, Object container)  
at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.\<\>c\_\_DisplayClass0\_0.\<g\_\_Bind|0\>d.MoveNext()  
--- End of stack trace from previous location ---  
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g\_\_Awaited|13\_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)  
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g\_\_Awaited|20\_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)  
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g\_\_Awaited|17\_0(ResourceInvoker invoker, Task task, IDisposable scope)  
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g\_\_Awaited|17\_0(ResourceInvoker invoker, Task task, IDisposable scope)  
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)  
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)  
at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)  
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)  
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)  
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)  
[13:54:07 INF] System.Net.Http.HttpClient.WXSAPIClient.ClientHandler - Received HTTP response headers after 112.8041ms - 500  
[13:54:07 INF] System.Net.Http.HttpClient.WXSAPIClient.LogicalHandler - End processing HTTP request after 126.8187ms - 500

---

<div class="post-metadata">

**Author:** ![enchev](https://forum.radzen.com/user_avatar/forum.radzen.com/enchev/32/16_2.png) [@enchev](https://forum.radzen.com/u/enchev)\
**Post date:** [January 27, 2026, 8:16am UTC](https://forum.radzen.com/t/errors-in-models-automatically-generated-from-postgresql/21316/2 "2026-01-27T08:16:53Z")

</div>

Thanks! It will be fixed in our next update!
