Aracılığıyla paylaş


EntityFrameworkServiceCollectionExtensions.AddEntityFramework Yöntem

Tanım

Dikkat

AddEntityFramework is no longer functional. Use AddEntityFrameworkSqlServer, AddEntityFrameworkSqlite, etc. instead.

Bu yöntem artık işlevsel değildir. AddEntityFrameworkSqlServer, AddEntityFrameworkSqlite gibi sağlayıcıya özgü bir yöntemi çağırma. Yer -ine.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddEntityFramework (this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection);
[System.Obsolete("AddEntityFramework is no longer functional. Use AddEntityFrameworkSqlServer, AddEntityFrameworkSqlite, etc. instead.", true)]
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddEntityFramework (this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection);
static member AddEntityFramework : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.Extensions.DependencyInjection.IServiceCollection
[<System.Obsolete("AddEntityFramework is no longer functional. Use AddEntityFrameworkSqlServer, AddEntityFrameworkSqlite, etc. instead.", true)>]
static member AddEntityFramework : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddEntityFramework (serviceCollection As IServiceCollection) As IServiceCollection

Parametreler

serviceCollection
IServiceCollection

Hizmet koleksiyonu.

Döndürülenler

Her zaman NotSupportedException oluşturur.

Öznitelikler

Özel durumlar

Her zaman NotSupportedException oluşturur.

Örnekler

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

    services.AddDbContext<MyContext>(options => options.UseSqlServer(connectionString)); 
}

Açıklamalar

Bu işlevi yalnızca Entity Framework'ün bir dıştan IServiceProviderkullandığı hizmetleri çözümlemesini istediğinizde kullanmanız gerekir. Dış IServiceProvider Entity Framework kullanmıyorsanız, gerekli hizmetleri oluştururken dikkatli olun.

Kullandığınız veritabanı, veritabanının gerektirdiği hizmetleri kaydetmek için döndürülen IServiceCollection üzerinde çağrılabilecek uzantı yöntemlerini de tanımlar. Örneğin, Microsoft.EntityFrameworkCore.SqlServer kullanırken çağrısı collection.AddEntityFrameworkSqlServer()yaparsınız.

türetilmiş bağlamların içinde IServiceProvider kaydedilmesi ve hizmetlerinden IServiceProvider çözümlenmesi için döndürülen IServiceCollectionüzerindeki yöntemine AddDbContext<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, ServiceLifetime) bir çağrı zincirlemeniz gerekir.

Şunlara uygulanır