Search code examples
entity-framework-corelinq2db

linq2db integration with Entity Framework Core and dbContext.GetCte missing


linq2db has possibility to "integrate" with EF Core context:

EF Core integration

In your code you need to initialize integration using following call: LinqToDBForEFTools.Initialize();

but after only that line there is no method GetCte in EF Core context.

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
    optionsBuilder.UseSqlServer("Server=.; Database=dbName;User Id=sa; Password=ble; encrypt=false", options => options.CommandTimeout(10))
                    .LogTo(Console.WriteLine, new[] { DbLoggerCategory.Query.Name, DbLoggerCategory.Database.Connection.Name, DbLoggerCategory.Database.Name }
                    );
                    // .UseQueryTrackingBehavior( QueryTrackingBehavior.NoTracking);
        
    LinqToDBForEFTools.Initialize();
}

USING

using (var _dbContext = new CompanyContext())
{
    _dbContext.GetCte - not found
    _dbContext.BulkCopy - found
}

Is it possible to use GetCte with EF Core DbContext or linq2db full configuration should be done to have a possibility to use recursive CTE?


Solution

  • seems to work

    using (var _dbContext = new CompanyContext())
    {
        using (var db = _dbContext.CreateLinqToDBConnection())
        {
    
        }
    }