/// <summary> /// Initializes the internal context, discovers and initializes sets, and initializes from a model if one is provided. /// </summary> private void InitializeLazyInternalContext(IInternalConnection internalConnection, DbCompiledModel model = null) { DbConfigurationManager.Instance.EnsureLoadedForContext(GetType()); _internalContext = new LazyInternalContext( this, internalConnection, model, DbConfiguration.GetService <IDbModelCacheKeyFactory>()); DiscoverAndInitializeSets(); }
private static DbProviderManifest GetProviderManifest(DbProviderInfo providerInfo) { DebugCheck.NotNull(providerInfo); var providerFactory = DbConfiguration.GetService <DbProviderFactory>(providerInfo.ProviderInvariantName); var providerServices = providerFactory.GetProviderServices(); var providerManifest = providerServices.GetProviderManifest(providerInfo.ProviderManifestToken); return(providerManifest); }
static TestBase() { #if NET452 SqlServerTypes.Utilities.LoadNativeAssemblies( Path.GetDirectoryName(typeof(FunctionalTestBase).Assembly.Location)); #endif DbConfiguration.SetConfiguration(new FunctionalTestsConfiguration()); // Uncomment below to log all test generated SQL to the console. //DbInterception.Add(new DatabaseLogFormatter(Console.Write)); }
public void LoadConfiguration_throws_for_invalid_arguments() { Assert.Equal( "assemblyHint", Assert.Throws <ArgumentNullException>(() => DbConfiguration.LoadConfiguration((Assembly)null)).ParamName); Assert.Equal( "contextType", Assert.Throws <ArgumentNullException>(() => DbConfiguration.LoadConfiguration((Type)null)).ParamName); Assert.Equal( Strings.BadContextTypeForDiscovery("Random"), Assert.Throws <ArgumentException>(() => DbConfiguration.LoadConfiguration(typeof(Random))).Message); }
private void MapTypes(EdmModel model) { DebugCheck.NotNull(model); var typeMapper = new TypeMapper( new MappingContext( _modelConfiguration, _conventionsConfiguration, model, _modelBuilderVersion, DbConfiguration.GetService <AttributeProvider>())); _modelConfiguration.Entities .Where(type => typeMapper.MapEntityType(type) == null) .Each(t => { throw Error.InvalidEntityType(t); }); _modelConfiguration.ComplexTypes .Where(type => typeMapper.MapComplexType(type) == null) .Each(t => { throw Error.CodeFirstInvalidComplexType(t); }); }
public void Dispose() { DbConfiguration.GetService <AttributeProvider>().ClearCache(); TypeDescriptor.RemoveProvider(_dynamicTypeDescriptionProvider, typeof(T)); }
static TestBase() { DbConfiguration.SetConfiguration(new FunctionalTestsConfiguration()); }
public void DbConfiguration_cannot_be_set_to_null() { Assert.Equal( "configuration", Assert.Throws <ArgumentNullException>(() => DbConfiguration.SetConfiguration(null)).ParamName); }
/// <summary> /// The Singleton instance of <see cref="DbConfiguration" /> for this app domain. This can be /// set at application start before any Entity Framework features have been used and afterwards /// should be treated as read-only. /// </summary> public static void SetConfiguration(DbConfiguration configuration) { Check.NotNull(configuration, "configuration"); InternalConfiguration.Instance = configuration.InternalConfiguration; }