示例#1
0
            public void Default_is_SqlServerConnectionFactory()
            {
#pragma warning disable 612,618
                Assert.IsType <SqlConnectionFactory>(Database.DefaultConnectionFactory);
#pragma warning restore 612,618
                Assert.IsType <SqlConnectionFactory>(DbConfiguration.GetService <IDbConnectionFactory>());
            }
示例#2
0
        /// <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();
        }
示例#3
0
        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);
        }
示例#4
0
        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));
 }