The entity type [NAME] is not part of the model for the current context. When compile in Release

StackOverflow https://stackoverflow.com/questions/20525466

  •  31-08-2022
  •  | 
  •  

Question

After generate my EDMX Model, and develop usual code do manage objects on the database with entityframework5, everyting works fine (selets, inserts, update and deletes) on Debug Mode.

The absolute same code when i go to deploy or run my webapp on Release Mode, on runtime i get an exception telling that a entity is not found: "The entity type [NAME] is not part of the model for the current context".

Is there something that i need to do, when my app runs on release mode?

thanks in advance for your help

Was it helpful?

Solution

Please verify that you have your variables assigned even with a null.

ProviderClass p = null;

Example:

[Debug mode Ok, Release error]

public class XPTO
{
    ProviderClass p;

    public start()
    {
        p = new ProviderClass();
    }

    public ProviderClass GetBy(long id)
    {
        return p.GetList<ProviderClass>()
                .Where(x => x.IDXPTO == id)
                .FirstOrDefault()
                .ToDomain();
    }
}

[Debug = ok, Release = ok]

    public class XPTO
{
    ProviderClass p = null;

    public start()
    {
        p = new ProviderClass();
    }

    public ProviderClass GetBy(long id)
    {
        return p.GetList<ProviderClass>()
                .Where(x => x.IDXPTO == id)
                .FirstOrDefault()
                .ToDomain();
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top