0

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
David Ferenczy Rogožan
  • 23,966
  • 9
  • 79
  • 68
Mohsen Zahedi
  • 651
  • 2
  • 10
  • 28
  • Possible duplicate of [Error 'The underlying provider failed on Open'](http://stackoverflow.com/questions/2475008/error-the-underlying-provider-failed-on-open) – David Ferenczy Rogožan Dec 14 '15 at 18:02
  • my connection string: – Mohsen Zahedi Dec 14 '15 at 19:55
  • 1
    This is a straight-up database connection error. If you're running in Visual Studio, then make sure that the file reference in your connection string exists. If you're running in IIS, either locally or on a remote server, you need to use a full SQL Server instance; LocalDB only exists inside Visual Studio. – Chris Pratt Dec 14 '15 at 21:00

0 Answers0