Mvc scaffolding option does not recognize the db context and says unsupported context type?
Dec 2, 2013 at 4:25 AM
Edited Dec 2, 2013 at 5:26 AM
The error is a Microsoft
. They say they have not fixed it yet..
The error occurs due to two reason
- Use of Partial class - we had partial model classes, but even after I remove them the error did not go away
- 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.
- Build your BLL first following the instructions given in codeplex
- Change the yourDBContext base class to 'DbContext' (i.e. replace the base class BaseObjectConext)
- Generate Views and Controllers using this new yourDBContext and the models
- Change yourDBContext back to its original form
- 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..