Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(floats) InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'System.Single', but this ViewDataDictionary instance requires a model item of type 'System.String'. #115

Open
joepperkins opened this issue Jan 5, 2025 · 2 comments

Comments

@joepperkins
Copy link

Any Entity property of type float causes the exception below

InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'System.Single', but this ViewDataDictionary instance requires a model item of type 'System.String'.

Steps to reproduce:

  1. Add the property below to DotNetEd.CoreAdmin.DemoApp.Models.TestEntity
    public float TaxRate { get; set; }
  2. Edit the TestEntity from the UI and throws an exception
@joepperkins
Copy link
Author

The implemented fix was to decorate the float property with [DataType(DataType.Text)] and the backend will catch any validation issues.

[DataType(DataType.Text)]
public float TaxRate { get; set; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@joepperkins and others