SqlServerServiceCollectionExtensions(IServiceCollection) Class (Microsoft.Extensions.DependencyInjection)

[ad_1]


Definition




SQL Server specific extension methods for .

public static class SqlServerServiceCollectionExtensions

Public Module SqlServerServiceCollectionExtensions





Inheritance

System.ObjectSystem.Object

SqlServerServiceCollectionExtensionsSqlServerServiceCollectionExtensions

Methods



AddEntityFrameworkSqlServer(IServiceCollection)
AddEntityFrameworkSqlServer(IServiceCollection)

Adds the services required by the Microsoft SQL Server database provider for Entity Framework
to an . You use this method when using dependency injection
in your application, such as with ASP.NET. For more information on setting up dependency
injection, see
http://go.microsoft.com/fwlink/?LinkId=526890.

You only need to use this functionality when you want Entity Framework to resolve the services it uses
from an external dependency injection container. If you are not using an external
dependency injection container, Entity Framework will take care of creating the services it requires.

public static IServiceCollection AddEntityFrameworkSqlServer(this IServiceCollection services)
<ExtensionAttribute>
Public Shared Function AddEntityFrameworkSqlServer(services As IServiceCollection) As IServiceCollection

Parameters

services


IServiceCollection
IServiceCollection

The to add services to.

Returns


IServiceCollection
IServiceCollection

The same service collection so that multiple calls can be chained.

Examples

     public void ConfigureServices(IServiceCollection services)
     
         var connectionString = "connection string to database";

         services
             .AddEntityFrameworkSqlServer()
             .AddDbContext<MyContext>((serviceProvider, options) =>
                 options.UseSqlServer(connectionString)
                        .UseInternalServiceProvider(serviceProvider));
     


Equals(Object)
Equals(Object)


Inherited from System.Object








Equals(Object, Object)
Equals(Object, Object)


Inherited from System.Object








GetHashCode()
GetHashCode()


Inherited from System.Object








GetType()
GetType()


Inherited from System.Object








MemberwiseClone()
MemberwiseClone()


Inherited from System.Object








ReferenceEquals(Object, Object)
ReferenceEquals(Object, Object)


Inherited from System.Object








ToString()
ToString()


Inherited from System.Object









[ad_2]

source_link
https://www.asp.net