Steps to reproduce:
@using System.Data.Entity;
@{
var db = Database.Open("WebPagesMovies");
//var selectCommand = "SELECT * FROM Movies";
//var searchTerm = "";
}
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>
My problem is, that the class Database is not recognized. The class is located in the system data entity namespace. If i do the same steps in a ASP .NET Web Application project, the reference is recognized. Because a website project has no csproj file, the references are placed in the web.config file. I see there following entry:
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
Does anybody get what i am missing here? Why can I not reference that namespace?
System.Data.Entity.Database
is only available for Entity Framework 5.0 and above: https://msdn.microsoft.com/en-us/library/system.data.entity.database%28v=vs.113%29.aspx
You need to ensure you have the correct version referenced. You will also need to ensure that your project is targeting the proper version of .Net Framework. You will need, I believe, .Net Framework 4.5 for Entity Framework 5+ to work properly.
You can download Entity Framework here: https://msdn.microsoft.com/en-us/data/ee712906.aspx