public void Initialize() { var assemblies = AppDomain.CurrentDomain.GetAssemblies(); var codeFirstTypes = new List<Type>(); foreach (Assembly assembly in assemblies) { IEnumerable<Type> types = assembly.GetLoadableTypes() .EmptyIfNull() .WithAttribute<CodeFirstAttribute>() .ToList(); codeFirstTypes.AddRange(types); } using (var factory = new DefinitionCreatorFactory(_sessionProvider)) { try { foreach (var type in codeFirstTypes) factory.Create(type); } catch (Exception e) { factory.Cancel(); throw new InvalidOperationException( "An error occured during creation of definitions. Any changes have been rolled back. See inner exception for details.", e); } } }
public void Initialize() { if (!_configurationProvider.Synchronize) return; var assembly = _configurationProvider.GetAssembly(); IEnumerable<Type> codeFirstTypes = assembly.GetTypes() .EmptyIfNull() .WithAttribute<CodeFirstAttribute>() .ToList(); using (var factory = new DefinitionCreatorFactory(_sessionProvider)) { try { foreach (var type in codeFirstTypes) factory.Create(type); } catch (Exception e) { factory.Cancel(); throw new InvalidOperationException( "An error occured during creation of definitions. Any changes have been rolled back. See inner exception for details.", e); } } }