Exemple #1
0
        private void RegisterSqlServerProvider()
        {
            var providerTypeName = string.Format(
                CultureInfo.InvariantCulture,
                "System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer, Version={0}, Culture=neutral, PublicKeyToken=b77a5c561934e089",
                new AssemblyName(typeof(DbContext).Assembly().FullName).Version);

            var provider = _providerServicesFactory.TryGetInstance(providerTypeName);

            if (provider != null)
            {
                // This provider goes just above the root resolver so that any other provider registered in code
                // still takes precedence, including any additional services registered by that provider.
                _internalConfiguration.SetDefaultProviderServices(provider, "System.Data.SqlClient");
            }
        }
        private void RegisterSqlServerProvider()
        {
            var providerTypeName = string.Format(
                CultureInfo.InvariantCulture,
                "System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer, Version={0}, Culture=neutral, PublicKeyToken=b77a5c561934e089",
                new AssemblyName(typeof(DbContext).Assembly.FullName).Version);

            var provider = _providerServicesFactory.TryGetInstance(providerTypeName);

            if (provider != null)
            {
                // This provider goes just above the root resolver so that any other provider registered in code
                // still takes precedence.
                _internalConfiguration.AddSecondaryResolver(
                    new SingletonDependencyResolver <DbProviderServices>(provider, "System.Data.SqlClient"));
                _internalConfiguration.AddSecondaryResolver(provider);
            }
        }