Solved

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

Posted on 2014-09-23
7
194 Views
Last Modified: 2014-09-27
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:
Complete Error MessageI 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

0
Comment
Question by:homeshopper
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 40339096
Hi homeshopper;

I am going to assume that you are using Database First in building your model because with Code First the table QuickQuote has defined a primary key because it uses convention over configuration which means that an entity which has Id anywhere in its name will be considered the primary key. Seeming that the exception states that "EntityType QuickQuote has no key defined". In order for Entity Framework to be able to do CRUD operations on an entity it must define a primary key. Therefore you will need to update the database and add a primary key to the QuickQuote table.
0
 

Author Comment

by:homeshopper
ID: 40339221
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

0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 40339261
Can you post a screen shot of the EDMX designer.
0
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 

Author Comment

by:homeshopper
ID: 40339343
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

0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 40339380
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.
0
 

Author Comment

by:homeshopper
ID: 40339392
Thank you for the help so far.
0
 

Author Closing Comment

by:homeshopper
ID: 40347318
Very helpful suggestions given, but final solution found elsewhere.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VS2010 Build fails to install 14 78
PowerShell:  Where-Object not working as a filter 2 72
Upgrade code from VS 2010 to VS 2015 7 32
Aspx calendar pop up control 3 28
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question