I'm trying to get EF4 working with ncommon 1.1 which provides DDD patterns such as UnitOfWork, Specification, Repository.
The NCommon configuration line is throwing the following Exception:
SynchronizationLockException occurred
Object synchronization method was called from an unsynchronized block of code.
The actual code throwing the error is:
.ConfigureData<EFConfiguration>(config => config.WithObjectContext(() => new CoreContext(connectionString)))
Here is the code that I am running.
private static void ConfigureIoc()
{
var container = new UnityContainer();
var serviceLocator = new UnityServiceLocator(container);
ServiceLocator.SetLocatorProvider(() => serviceLocator);
container
.RegisterType(typeof(IUnitOfWorkScope), typeof(UnitOfWorkScope), new InjectionConstructor())
.RegisterType(typeof(IList<>), typeof(List<>), new InjectionConstructor())
.RegisterType<IVerticalRepository, EfVerticalRepository>()
;
const string connectionString =
@"metadata=res://*/Core.csdl|res://*/Core.ssdl|res://*/Core.msl;provider=System.Data.SqlClient;provider connection string="";Data Source=devdatabase;Initial Catalog=InfoChoiceAdmin;Persist Security Info=True;User ID=sa;Password=sa;MultipleActiveResultSets=True""";
var adapter = new UnityContainerAdapter(container);
NCommon.Configure.Using(adapter)
.ConfigureState<DefaultStateConfiguration>()
.ConfigureData<EFConfiguration>(config => config.WithObjectContext(() => new CoreContext(connectionString)))
.ConfigureUnitOfWork<DefaultUnitOfWorkConfiguration>(config => config.AutoCompleteScope());
Ioc.Initialize(serviceLocator);
}