Lingua

DatabaseFacade.EnsureDeleted Metodo

Definizione

Assicura che il database per il contesto non esista. Se non esiste, non viene eseguita alcuna azione. Se esiste, il database viene eliminato.

Avviso: l'intero database viene eliminato e non viene eseguito alcun tentativo di rimuovere solo gli oggetti di database utilizzati dal modello per questo contesto.

public virtual bool EnsureDeleted();
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Migrations operations require building the design-time model which is not supported with NativeAOT Use a migration bundle or an alternate way of executing migration operations.")]
public virtual bool EnsureDeleted();
abstract member EnsureDeleted : unit -> bool
override this.EnsureDeleted : unit -> bool
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Migrations operations require building the design-time model which is not supported with NativeAOT Use a migration bundle or an alternate way of executing migration operations.")>]
abstract member EnsureDeleted : unit -> bool
override this.EnsureDeleted : unit -> bool
Public Overridable Function EnsureDeleted () As Boolean

Valori restituiti

true se il database viene eliminato, false se non esiste.

Attributi

Commenti

È comune usare EnsureCreated() immediatamente dopo EnsureDeleted() il test o la creazione di prototipi con Entity Framework. In questo modo si garantisce che il database sia in uno stato pulito prima di ogni esecuzione del test/prototipo. Si noti, tuttavia, che i dati nel database non vengano mantenuti.

Per altre informazioni ed esempi, vedere Managing database schemas with EF Core and Database creation APIs (Gestione degli schemi di database con EF Core e API di creazione di database).

Si applica a