EntityFrameworkServiceCollectionExtensions.AddEntityFramework Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Dikkat
AddEntityFramework is no longer functional. Use AddEntityFrameworkSqlServer, AddEntityFrameworkSqlite, etc. instead.
Bu yöntem artık işlevsel değildir. Bunun yerine AddEntityFrameworkSqlServer, AddEntityFrameworkSqlite gibi sağlayıcıya özgü bir yöntemi çağırabilirsiniz.
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.
- Özellikler
Ö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ış IServiceProvideruygulamasından kullandığı hizmetleri çözümlemesini istediğinizde kullanmanız gerekir. Dış IServiceProvider Entity Framework kullanmıyorsanız, gerekli hizmetleri oluşturmakla ilgilenir.
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 kullanırken. Çağıracağınız collection.AddEntityFrameworkSqlServer()EntityFrameworkCore.SqlServer.
türetilmiş bağlamların içinde IServiceProvider kaydedilip 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.