my project name was MVC and I had this class
public class download { public int download_id { get; set; } public int download_category_id { get; set; } public string download_name { get; set; } public int download_size { get; set; } public string download_description { get; set; } public string download_path { get; set; } public download_category download_category { get; set; } } public class download_category { public int download_category_id { get; set; } public string download_category_name { get; set; } } public class DownloadDbContext : DbContext { public DbSet<download> downloads { get; set; } public DbSet<download_category> download_categorys { get; set; } }
and I got a similar error when creating forests (an error occurred while trying to restore your project). I am using Visual Studio 2012 version 11.0.50727.1 RTMREL and an object reference as ... \ EntityFramework.5.0.0 \ lib \ net45 \ EntityFramework.dll
I first divide the class into three classes (three separate * .cs files), and also use DataAnnotations in the download and download_category classes to use [key] for the id and problem columns.
my classes were lower in the Models folder:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using MVC.Models; using System.ComponentModel.DataAnnotations; namespace MVC.Models { public class Download { [Key] public int download_id { get; set; } public int download_category_id { get; set; } public string download_name { get; set; } public int download_size { get; set; } public string download_description { get; set; } public string download_path { get; set; } public Download_category download_category { get; set; } } }
and
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel.DataAnnotations; namespace MVC.Models { public class Download_category { [Key] public int download_category_id { get; set; } public string download_category_name { get; set; } } }
and
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data.Entity; namespace MVC.Models { public class DownloadDbContext:DbContext { public DbSet<Download> downloads { get; set; } public DbSet<Download_category> download_categorys { get; set; } } }
source share