Here are my models:
public partial class NEWS
{
public NEWS()
{
}
[Key]
public int NEWSID { get; set; }
public string Title { get; set; }
public string Text { get; set; }
public string InsertDate { get; set; }
public int GroupingID { get; set; }
public virtual Subjects Subjects { get; set; }
}
public partial class Subjects
{
public Subjects()
{ this.NEWSs = new HashSet<NEWS>(); }
[Key]
public int GroupingID { get; set; }
public string Farsi { get; set; }
public string Latin { get; set; }
public virtual ICollection<NEWS> NEWSs { get; set; }
}
public class UserGroup
{
public UserGroup()
{ this.Userss = new HashSet<Users>(); }
[Key]
public int UserID { get; set; }
public string Title { get; set; }
public virtual ICollection<Users> Userss { get; set; }
}
public class Users
{
public Users()
{ }
public string Name { get; set; }
public string Family { get; set; }
public string Email { get; set; }
public string UserName { get; set; }
public string PassWord { get; set; }
[Key]
public int UserID { get; set; }
public virtual UserGroup UserGroup { get; set; }
// public HashSet<Users> Userss { get; set; }
}
public class NEWSDBContext : DbContext
{
public NEWSDBContext()
: base()
{
Database.SetInitializer<NEWSDBContext>(null);
}
public DbSet<NEWS> NEWSs { get; set; }
public DbSet<Users> Userss { get; set; }
public DbSet<UserGroup> UserGroups { get; set; }
public DbSet<Subjects> Subjectss { get; set; }
}
I always get an error in return View(newss.ToList());
:
The underlying provider failed on Open