Error when starting Context Entity Framework: Function requires all threads to be executed

1

I have a solution that has some projects working, they all refer to the Domain layer, which is responsible for connecting to the Oracle Database .

I created a project in Console referencing Domain, like the other projects and when I start the Context I get the following error:

  

Function evaluation requires all threads to be run.

This in debug when I'm building the instance of OpusDbContext, at the time of starting Database.SetInitializer (null) ;

I put a Try-Cath to see the exception and generated:

  

InnerException = {"The provider did not return a ProviderManifestToken string."}

     

Message ="An error occurred while getting provider information from the database." This can be caused by Entity Framework using an incorrect connection string. correct. "

Code

//OpusDbContext esta na minha camada de Domínio
public OpusDbContext()
        : base("OpusDbContext")
    {
        Principal = new OpusPrincipal();
        Database.SetInitializer<OpusDbContext>(null);

    }

class Program
{
    static void Main(string[] args)
    {

        using (var context = new OpusDbContext())
        {

            var query = from p in context.Balanca
                        select p;

            var result = query.FirstOrDefault();
            Console.WriteLine(result.DescricaoBalanca);
        }

        Console.ReadKey();
    }
}

Where am I going wrong? Any solution?

    
asked by anonymous 23.01.2018 / 13:23

1 answer

0

For some reason that I have not yet discovered, Entity Framewor or Oracle Connection Drivers could not find my tnsnames.ora .

So I found a workaround for this problem, putting the connection string right in the constructor of my Context and it worked.

Example:

public class TolfluxDbContext : DbContext
{
    private static string connectionString = "DATA SOURCE=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx.xxx.xx.xxx)(PORT=1521)))(CONNECT_DATA=(SID=xxxx))));PASSWORD=xxxx;USER ID=xxxx";

    public TolfluxDbContext():base(connectionString)
    {            
        Database.SetInitializer<TolfluxDbContext>(null);
    }
}
    
26.01.2018 / 14:45