locked
Cannot add a view for the controller method RRS feed

  • Question

  • User-1128363788 posted

    I wanted to add a view for the controller method as shown below:

    I got this error when I clicked add:

    I tried building my project. I also tried restarting my VS but the error exists.

    And this is my ApplicationDbContext Class:
    Thanks.

    Monday, June 17, 2019 1:53 PM

All replies

  • User1520731567 posted

    Hi mahmoud_arafa,

    Firstly,make sure you rebuild your solution first. If you just added a new class, the scaffolding engine may not actually know about it, yet, if the project hasn't compiled.

    If that doesn't work, close Visual Studio and restart. 

    According to your error message,There may be a lot of details that cause this error.

    Maybe this due to the Controller scaffolding is not properly recognizing connection string in web.config file.

    In Web.config, check your providerName in connectionStrings and after creating controller, undo that!

    this solution from this link and this video.

    or

    right clicking the controller action was to leave the "Data context class" field blank,like:

    this solution from this link.

    If none of the above solves the problem,please post your model.

    Best Regards.

    Yuki Tao

    Tuesday, June 18, 2019 5:42 AM