Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

could not get the reflection type for model

Step 1 : right click to generate

this is my first step

Step 2 : setting

enter image description here

Step 3 : error message

My Vs2017 popup this error message, when i create the view from controller

Step 4 : my Model

enter image description here

how to settle this ? i cant generate create form

like image 647
Neo Yap Avatar asked Apr 27 '17 15:04

Neo Yap


3 Answers

So far even if you try to add say, another view for an existing controller and an existing action, say ManageController.AddPhoneNumber with the existing view model - AddPhoneNumberViewModel, still the same exception is thrown despite there is already a view for the very same action and controller, using the very same view model.

No need to upload any more screenshots, or anything else, the problem seems to be in the VS 2017 code generator (a scaffolding view issue), and hopefully will be addressed in some of the following updates.

So be patient and use the copy/paste approach, you'll need to redesign your form anyway. Apparently, this is not a solution to your (my) problem, it only says - "you did nothing wrong, it's a VS bug, wait for an update".

like image 172
Alexander Christov Avatar answered Nov 07 '22 16:11

Alexander Christov


I have faced this and similar issues relating to scaffolding a number of times, and my goto solution works pretty much every time - including for this specific issue.

  1. Right click Solution file
  2. Select "Rebuild Solution"

...And then try your action again.

This has worked for me many times in VS2017 and VS2019 - including today with the latest VS 2019.

It seems the scaffolding is being tripped up by something that is already built, for reasons unknown.

like image 38
Kjensen Avatar answered Nov 07 '22 15:11

Kjensen


I also had the same problem, make sure there are no issues in your controller, I had unfinished code that caused the error, once I commented it out it created the view without any problems.

like image 2
Haas Avatar answered Nov 07 '22 17:11

Haas