Input tag helpers require checkboxes to be bound to non-nullable boolean fields yet my legacy sql tables contain nullable tinyint fields. Existing data is 1, 0 or Null. Entity Framework generates nullable byte? properties for those fields in the model. My razor page is bound directly to the generated database model. Now I want to bind checkboxes to those fields. What options are available? Changing the database is not possible.
Should I make matching bound boolean properties in the razor page model? In the get/set I could pull/push converted values to the database model's byte? fields. In the past (using non-razor MVC) I've bound my page to a viewmodel with the generated model hanging off of it in a property. That allowed me to bind to the viewmodel and "fix" data issues in the controller.
I'll try that idea but I'm wondering if I'm heading down the wrong path?
EDIT: I found a solution which I'll post as an answer. My original idea (above) failed (coding in property get/set) because the database model was null at that time. Instead I pull/push values in the OnGet and OnPost routines. Still I'm not sure if the is the preferred way to solve the problem.