This project is read-only.

unsupported context type error

Dec 2, 2013 at 5:11 AM
Mvc scaffolding option does not recognize the db context and says unsupported context type?
Marked as answer by RocketFramework on 12/1/2013 at 10:31 PM
Dec 2, 2013 at 5:25 AM
Edited Dec 2, 2013 at 6:26 AM
The error is a Microsoft error. They say they have not fixed it yet..

The error occurs due to two reason
  1. Use of Partial class - we had partial model classes, but even after I remove them the error did not go away
  2. yourDBContext class is not directly derived from the 'DbContext' - In Nido framework, we have the BaseObjectConext in between yourDBContext and the system DbContext. That is the reason for this error. However it is up to MSFT to fix this error in the future.
If you want to use MVC scaffolding option to generate your views (I believe you do), please follow the given steps. This is a workaround to avoid the said error.
  1. Build your BLL first following the instructions given in codeplex
  2. Change the yourDBContext base class to 'DbContext' (i.e. replace the base class BaseObjectConext)
  3. Generate Views and Controllers using this new yourDBContext and the models
  4. Change yourDBContext back to its original form
  5. Change the Controller to use the respective Handler, instead of yourDBContext (because directly using yourDBContext will not inherit many other features given by Nido framework, which include error handling, custom message to display for users, audit trail, debug mode facility etc)
If you need to read about this issues more, stack overflow has a thread..
http://stackoverflow.com/questions/9116601/mvc3-add-controller-scaffolding-error-unsupported-context-type
Marked as answer by RocketFramework on 12/1/2013 at 10:31 PM