title: How to set a Foreign Key relationship manually in LINQ To SQL
body: <p>I've been working through the book Pro ASP.NET MVC 2 Framework by Steven Sanderson. So far it's been phenominal... just when i think I know a decent amount I find a book that shows me just how little I know.</p>
  
  <p>One of the things I know little about is how to use LINQtoSQL. In Steven's book, chapters 4-6 create a very nice little shopping cart. I went through the tutorial and got everything working. Now I want to modify the cart to use a Category table instead of storing the category name as a varchar in the Product table.</p>
  
  <p>Here's the Product table object with my changes to have CategoryID as a foreign key relationship to the Categories Table.</p>
  
  <pre><code>    [Table(Name="Products")]
      public class Product
      {
          [HiddenInput(DisplayValue=false)]
          [Column(IsPrimaryKey=true, IsDbGenerated=true, AutoSync=AutoSync.OnInsert)]
          public int ProductID { get; set; }
  
          [Required(ErrorMessage="Please enter a product name")]
          [Column] public string Name { get; set; }
  
          [Required(ErrorMessage="Please enter a description")]
          [DataType(DataType.MultilineText)]
          [Column] public string Description { get; set; }
  
          [Required]
          [Range(0.01, double.MaxValue, ErrorMessage="Please enter a positive price")]
          [Column] public decimal Price { get; set; }
  
  
          [Required(ErrorMessage="Please enter a category")]
          [Column] public int CategoryID { get; set; }
  
          internal EntityRef&lt;Category&gt; _category;
          [System.Data.Linq.Mapping.Association(ThisKey = "CategoryID", Storage = "_category")]
          public Category Category {
              get { return _category.Entity; }
              internal set { _category.Entity = value; CategoryID = value.CategoryID; }
          }
  
  
          [Column] public byte[] ImageData { get; set; }
  
          [ScaffoldColumn(false)]
          [Column] public string ImageMimeType { get; set; }
  </code></pre>
  
  <p>And here is my Category class</p>
  
  <pre><code>    [Table(Name="Categories")]
      class Category
      {
          [Column(IsPrimaryKey=true, IsDbGenerated=true, AutoSync=AutoSync.OnInsert)]
          internal int CategoryID { get; set; }
  
          [Column]
          public int ParentCategoryID { get; set; }
  
          [Column]
          [Required]
          public string Name { get; set; }
      }
  </code></pre>
  
  <p>When I tried to build this code, i got an error that I don't understand:</p>
  
  <blockquote>
    <p>Inconsistent accessibility: property type 'SportsStore.Domain.Entities.Category' 
    is less accessible than property 'SportsStore.Domain.Entities.Product.Category'</p>
  </blockquote>
  
  <p>What does that mean / How would I fix this?</p>