0

I have a web page using Entity Framework that stopped working. I'm rebuilding it in VS2017. I have no errors when compiling, but when accessing the webpage I get:


Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name 'ausoftus_dbEntities1' could not be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 16: Line 17: Line 18: ausoftus_dbEntities1 db = new ausoftus_dbEntities1();


My EF is called 'Patriots'. If I encapsulate the function in a namespace in Patriots.Context.cs, my code also compiles fine referencing that namespace. But the web page returns the error that it can't find the namespace.

I checked that my project uses the same .Net version as the EF. The project properties shows Target Framework: .NET Framework 4.6.1. I'm using EF 6.2.

In Patriots.Context.cs (within App_Code folder):

using System.Data.Entity;
using System.Data.Entity.Infrastructure;

public partial class ausoftus_dbEntities1 : DbContext
{
    public ausoftus_dbEntities1()
        : base("name=ausoftus_dbEntities1")
    {
    }

How do I make sure that System.Data.Entity is the right version?

Shaun
  • 1
  • 1
    The way you solve this problem is the same as the way you solve it everywhere else: by resolving the broken references. Most of the solution is described in the error message itself. I doubt that the version of System.Data.Entity you're using is the actual problem. – Robert Harvey Jan 01 '19 at 19:59
  • The reference isn't broken in VS, so I don't seen anything to resolve. How does one 'resolve the broken reference"? – Shaun Jan 01 '19 at 23:05
  • Are you missing a `using` directive? – Robert Harvey Jan 01 '19 at 23:08
  • I don't have any errors in VS. What would I use, anyway? System.Data.Entity? When I add that, it says that it's unnecessary. ausoftus_dbEntities1 is declared in Patriots.Context.cs. Using doesn't allow the class name in my default.aspx.cs file. As stated above, if you put a namespace in Patriots.Context.cs I can add a 'using' with the namespace, but then I get the 0246 for the using declaration. It's as if the published location can't find the EF files. – Shaun Jan 02 '19 at 02:16
  • Are you properly distributing EF with your application? – Robert Harvey Jan 02 '19 at 02:23
  • I've published my project, the EF files and EntityFramework.dll. Searching for 'distributing EF' to see what I'm missing. – Shaun Jan 02 '19 at 02:57

0 Answers0