Link to home
Start Free TrialLog in
Avatar of homeshopper
homeshopperFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Unable to retrieve metadata for 'Nop.Web.QuickQuote.QuickQuote'

I am trying to make quickquoteController.cs and get the following error:
Unable to retrieve metadata for 'Nop.Web.QuickQuote.QuickQuote'
I am not sure what I am doing wrong.
Thanks in advance for any help given.
The complete error message is as per embeded image:
User generated imageI built  the QuickQuote.cs Model first & compiled the project.
The controller information is as follows:
Controllers=>quickquoteController.cs

Controller with read/write actions and views, using Entity Framework
Variant(Nop.Web.Models.QuickQuote)
quickquoteDBContext (Nop.Web.Models.QickQuote)
Razor (cshtml)
Reference script libraries
use layout Views=>Shared=>_ColumnsThree.cshtml

Open in new window

The Model code is as follows:
Models=>QuickQuote=>QickQuote.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;

namespace Nop.Web.Models.QuickQuote
{
    public class QuickQuote
    {
        public int ProductId { get; set; }
        public String Name { get; set; }
        public String OldPriceMP { get; set; }
        public String OldPrice { get; set; }
    }
    public class quickquoteDBContext : DbContext
    {
        public DbSet<QuickQuote> ProductVariant { get; set; }
    }
}

Open in new window

The Web.Config and RouteProvider code is as follows:
web.config

<connectionStrings>
<add name="quickquoteDBContext" connectionString="Data Source=(local);Initial Catalog=CorpWear265_Restore_TestAlt;User ID=sa;Password=H6web97!;" providerName="System.Data.SqlClient"/>
</connectionStrings>

Infrastructure=>RouteProvider.cs

			//quickquotePage
            routes.MapLocalizedRoute("quickquotePage",
                            "QickQuote/",
                            new { controller = "quickquote", action = "Index" },
                            new[] { "Nop.Web.Controllers" });

Open in new window

The Menu code is as follows:
<li>
       <a href="@Url.RouteUrl("ProductSearch")">Advanced<br />Search</a>
        <ul>
            <li><a href="@Url.RouteUrl("quickquotePage")"></a></li>
            <li><a href="@Url.RouteUrl("moviePage")"></a></li>
        </ul>
    </li>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of homeshopper

ASKER

Thank you for your response.
The database CorpWear265_Restore_TestAlt.mdf is already constructed with
Table ProductVariant not QuickQuote.
The table structure is as below:
Thanks in advance.
id Int Primary Key
ProductId int
Name nvarchar(400) allow nulls
OldPrice decimal(18,4)
OldPriceMP navarchar(50)
The model code is below:
namespace Nop.Web.Models.QuickQuote
{
    public class QuickQuote
    {
        public int ProductId { get; set; }
        public String Name { get; set; }
        public String OldPriceMP { get; set; }
        public String OldPrice { get; set; }
    }
    public class quickquoteDBContext : DbContext
    {
        public DbSet<QuickQuote> ProductVariant { get; set; }
    }
}

Open in new window

Can you post a screen shot of the EDMX designer.
Thank you for the response.
I am using NopCommerce and do not think it has an EDMX file.
However, I placed public int Id { get; set; } in the model QuickQuote
public class QuickQuote
    {
      public int Id { get; set; }
      public int ProductId { get; set; }
and now was able to build quickquoteController.cs
I get a new error in quickquoteController.cs as below:
Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'dbo.QuickQuotes'.
Source Error: 
Line 16:         public ViewResult Index()
Line 17:         {
Line 18:             return View(db.ProductVariant.ToList());
Line 19:         }
Line 20:         // GET: /quickquote/Details/5
Source File: C:\Users\Ian\aaaNopComProjects\webApp-AltSourceFinal\Presentation\Nop.Web\Controllers\quickquoteController.cs    Line: 18

Open in new window

Sorry I did not know that NopCommerce is a product like Entity Framework. I do not have any knowledge of the product and how it works and would not be able to help, sorry.
Thank you for the help so far.
Very helpful suggestions given, but final solution found elsewhere.