Created
November 3, 2024 13:46
-
-
Save karenpayneoregon/fcc1b1fbe688b40539562730f2d2f389 to your computer and use it in GitHub Desktop.
EF Core does database exists method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using yournamespace.Data; | |
using Microsoft.EntityFrameworkCore.Infrastructure; | |
using Microsoft.EntityFrameworkCore.Storage; | |
namespace yournamespace.Classes; | |
internal class EntityHelpers | |
{ | |
public static bool DatabaseExists() | |
{ | |
using var context = new Context(); | |
return ((RelationalDatabaseCreator)context.Database.GetService<IDatabaseCreator>()).Exists(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment