Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this Blazor error message mean?

Tags:

blazor

If I told you that "You require sunglasses or an umbrella but not both." you would have no idea if it is raining or not. When running my Blazor web application I get

EditForm requires a Model parameter, or an EditContext parameter, but not both

My code has:

<EditForm Model="@order" OnSubmit="OnSubmit">

so as far as I know I am only using a Model parameter. I think use of the word 'Or' in error messages should be banned. My guess is that something has auto generated EditContext. Has anybody got any idea where to look?

like image 522
Paul McCarthy Avatar asked Oct 21 '25 13:10

Paul McCarthy


1 Answers

Did you create an instance for the variable @order? You will get this error message if you defined @order but leave it null.

If that's the case, it relates to the admittedly awkward error message because "EditForm requires a Model parameter, or an EditContext parameter", but you provided neither.

See: ASP.NET Core Blazor forms and validation : Troubleshoot

When assigning a Model to the form, confirm that the model type is instantiated

like image 134
Eric King Avatar answered Oct 23 '25 09:10

Eric King