Share via


EntityFrameworkServicesBuilder 類別

定義

建置器 API,專為註冊服務時要使用的資料庫提供者所設計。

public class EntityFrameworkServicesBuilder : Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.Extensions.DependencyInjection.IServiceCollection>
public class EntityFrameworkServicesBuilder
type EntityFrameworkServicesBuilder = class
    interface IInfrastructure<IServiceCollection>
type EntityFrameworkServicesBuilder = class
Public Class EntityFrameworkServicesBuilder
Implements IInfrastructure(Of IServiceCollection)
Public Class EntityFrameworkServicesBuilder
繼承
EntityFrameworkServicesBuilder
衍生
實作

備註

提供者應該建立這個類別的實例、使用其方法來註冊服務,然後呼叫 TryAddCoreServices() 以填寫其餘的 Entity Framework 服務。

關聯式提供者應該改用 'EntityFrameworkRelationalServicesBuilder。

Entity Framework 可確保服務已向適當的範圍註冊。 在某些情況下,提供者可能會向不同的範圍註冊服務,但請務必小心,其所有相依性都可以處理新的範圍,而且它不會對相依的服務造成問題。

如需詳細資訊和範例,請參閱 資料庫提供者和延伸模組的實作

建構函式

EntityFrameworkServicesBuilder(IServiceCollection)

資料庫提供者用來建立新的 EntityFrameworkServicesBuilder 提供者服務註冊。 關聯式提供者應該使用 'EntityFrameworkRelationalServicesBuilder'。

欄位

CoreServices

這是支援 Entity Framework Core 基礎結構的內部 API,不受與公用 API 相同的相容性標準。 它可能會在任何版本中變更或移除,而不會有任何通知。 您應該只在程式碼中直接使用它,並知道這麼做可能會導致應用程式在更新至新的 Entity Framework Core 版本時失敗。

屬性

ServiceCollectionMap

基礎 的 ServiceCollectionMap 存取權。

方法

GetServiceCharacteristics(Type)

ServiceCharacteristics取得指定服務型別的 。

TryAdd(Type, Object)

只有在尚未註冊 Entity Framework 服務時,才新增 Entity Framework 服務的實作。 這個方法只能用於單一服務。

TryAdd(Type, Type)

只有在尚未註冊 Entity Framework 服務時,才新增 Entity Framework 服務的實作。 Entity Framework 會自動定義服務的範圍。

TryAdd(Type, Type, Func<IServiceProvider,Object>)

只有在尚未註冊 Entity Framework 服務時,才新增 Entity Framework 服務的處理站。 Entity Framework 會自動定義服務的範圍。

TryAdd<TService,TImplementation>()

只有在尚未註冊 Entity Framework 服務時,才新增 Entity Framework 服務的實作。 Entity Framework 會自動定義服務的範圍。

TryAdd<TService,TImplementation>(Func<IServiceProvider,TImplementation>)

只有在尚未註冊 Entity Framework 服務時,才新增 Entity Framework 服務的處理站。 Entity Framework 會自動定義服務的範圍。

TryAdd<TService>(Func<IServiceProvider,TService>)

只有在尚未註冊 Entity Framework 服務時,才新增 Entity Framework 服務的處理站。 Entity Framework 會自動定義服務的範圍。

TryAdd<TService>(TService)

只有在尚未註冊 Entity Framework 服務時,才新增 Entity Framework 服務的實作。 這個方法只能用於單一服務。

TryAddCoreServices()

註冊提供者尚未註冊之所有服務的預設實作。 資料庫提供者必須呼叫這個方法作為服務註冊的最後一個步驟,也就是註冊所有提供者服務之後。

TryAddProviderSpecificServices(Action<ServiceCollectionMap>)

資料庫提供者應該呼叫這個方法來存取基礎 ServiceCollectionMap ,以便註冊提供者特定的服務。 請注意,Entity Framework 服務的實作應該直接在 上 EntityFrameworkServicesBuilder 註冊,而不是透過此方法註冊。

TryGetServiceCharacteristics(Type)

ServiceCharacteristics取得指定服務型別的 。

明確介面實作

IInfrastructure<IServiceCollection>.Instance

取得正在設定的 IServiceCollection

此屬性適用于需要利用公用 API 介面中未直接公開之服務的擴充方法。

擴充方法

GetInfrastructure<T>(IInfrastructure<T>)

從使用 IInfrastructure<T> 隱藏的屬性取得值。

這個方法通常由資料庫提供者使用, (和其他延伸模組) 。 它通常不會用於應用程式程式碼中。

適用於