相关疑难解决方法(0)

在EF中正确使用IDatabaseInitializer是什么?

我有一个自定义DatabaseInitialiser,如下所示

/// <summary>
/// Implements the IDatabaseInitializer to provide a custom database initialisation for the context.
/// </summary>
/// <typeparam name="TContext">TContext is the DbContext</typeparam>
public class ParikshaDataBaseInitializer<TContext> : IDatabaseInitializer<TContext> where TContext : DbContext
{
    /// <summary>
    /// The method to Initialise the database.
    /// Takes care of the database cannot be dropped since it is in use problem while dropping and recreating the database.
    /// </summary>
    /// <param name="context">The DbContext on which to run the initialiser</param>
    public void InitializeDatabase(TContext context) …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework ef-code-first ef-migrations entity-framework-6

17
推荐指数
1
解决办法
1万
查看次数