We have been using dotConnect for MySQL version 7.6.217 for a long time. Now we wanted to upgrade to the latest version (8.6.743 at the moment) but got into trouble with lazy loading.
The exception is "Commands out of sync; You can't run this command now" when trying to access a navigation property that has not been loaded with the initial query:
Code: Select all
using System;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
try
{
var context = new TestDevModel.TestDevEntities();
var orders = context.Orders.Include("OrderEvents.Address");
foreach (var order in orders)
{
foreach (var orderEvent in order.OrderEvents)
{
if (orderEvent.Address != null)
{
// This will throw an exception:
// "Commands out of sync; You can't run this command now"
var type = orderEvent.Address.AddressType;
}
}
}
}
catch (Exception ex)
{
}
}
}
}
Code: Select all
var orders = context.Orders.Include("OrderEvents.Address.AddressType");
We have created the model from scratch with database first to make sure we don't have messed up something. So the model (edml) is using all default settings which includes LazyLoading.
Do you have any idea what could be causing this issue?
Regards
Andreas