title: Error!System.Data.Entity.Core.MetadataException: Schema specified is not valid
body: <p>I am working on an E-commerce website but stuck on this error. Been stuck on this error took me hours to resolve this problem but cant help out.</p>
  
  <p><strong>Entities:</strong></p>
  
  <pre><code>public partial class Cart
  {
  public int ID { get; set; }
  public string ClientID { get; set; }
  public int ProductID { get; set; }
  public int Amount { get; set; }
  public Nullable&lt;System.DateTime&gt; DatePurchased { get; set; }
  public bool IsInCart { get; set; }
  
  public virtual Product Product { get; set; }
  }
  
  public partial class Product
  {
  public Product()
  {
      this.Carts = new HashSet&lt;Cart&gt;();
  }
  
  public int ID { get; set; }
  public int TypeID { get; set; }
  public string Name { get; set; }
  public double Price { get; set; }
  public string Description { get; set; }
  public string Image { get; set; }
  
  public virtual ICollection&lt;Cart&gt; Carts { get; set; }
  public virtual ProductType ProductType { get; set; }
  }
  
  public partial class ProductType
  {
  public ProductType()
  {
      this.Products = new HashSet&lt;Product&gt;();
  }
  
  public int ID { get; set; }
  public string Name { get; set; }
  
  public virtual ICollection&lt;Product&gt; Products { get; set; }
  }
  </code></pre>
  
  <p><strong>Model</strong></p>
  
  <p>The entities and their mappings are correctly registered with Entity Framework.
  [![enter image description here][1]][1]</p>
  
  <p><strong>Error</strong>
  Error I have been facing is shown below:</p>
  
  <blockquote>
    <p>Error!System.Data.Entity.Core.MetadataException: Schema specified is not valid. Errors: The relationship 'GarageDBModel.FK_Cart_Product' was not loaded because the type 'GarageDBModel.Product' is not available. The following information may be useful in resolving the previous error: The required property 'Id' does not exist on the type 'Product'. at System.Data.Entity.Core.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(Assembly assembly, Boolean loadReferencedAssemblies, EdmItemCollection edmItemCollection, Action<code>1 logLoadMessage) at System.Data.Entity.Core.Metadata.Edm.ObjectItemCollection.ExplicitLoadFromAssembly(Assembly assembly, EdmItemCollection edmItemCollection, Action</code>1 logLoadMessage) at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.ExplicitLoadFromAssembly(Assembly assembly, ObjectItemCollection collection, Action<code>1 logLoadMessage) at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.LoadFromAssembly(Assembly assembly, Action</code>1 logLoadMessage) at System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.LoadFromAssembly(Assembly assembly) at System.Data.Entity.Core.Metadata.Edm.MetadataOptimization.TryUpdateEntitySetMappingsForType(Type entityType) at System.Data.Entity.Internal.InternalContext.TryUpdateEntitySetMappingsForType(Type entityType) at System.Data.Entity.Internal.InternalContext.UpdateEntitySetMappingsForType(Type entityType) at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) at System.Data.Entity.Internal.Linq.InternalSet<code>1.Initialize() at System.Data.Entity.Internal.Linq.InternalSet</code>1.get_InternalContext() at System.Data.Entity.Internal.Linq.InternalSet<code>1.ActOnSet(Action action, EntityState newState, Object entity, String methodName) at System.Data.Entity.Internal.Linq.InternalSet</code>1.Add(Object entity) at System.Data.Entity.DbSet`1.Add(TEntity entity) at ProductTypeModel.InsertProductType(ProductType productType) in c:\Users\Ch Umer\Documents\Visual Studio 2012\WebSites\Garage\App_Code\Models\ProductTypeModel.cs:line 16</p>
  </blockquote>