Entity Framework Code First Database Recovery Model

c# entity-framework-6 sql sql-server

Question

Is is possible to set the Recovery Model mode of an SQL database created using Entity Framework 6? I know it's possible to set it through the following SQL statement:

ALTER DATABASE [Database_Name] SET RECOVERY SIMPLE;

It seems odd that this can't be set as a part of the configuration of the DbContext - the object which creates the database can't seem to control how it's created. I was expecting to find something like the following:

public class MyContext : DbContext
{
    public MyContext(string connectionString) : base(connectionString)
    {
        // This is where I would have expected to be able to set the recovery model type
        Database.RecoveryModel = RecoveryModelType.Simple;
    }
}

My suspicion is that this isn't possible due to EF being (largely) DB provider agnostic and recovery model being MSSQL specific, but I'm hoping that I'm wrong.

1
9
7/3/2017 9:29:36 AM

Popular Answer

Not in a way you want it to.

EF works with different SQL providers and what is relevant for MS SQL, might be inappropriate for MySQL.

However you can always run raw TSQL and do whatever you want.

1
6/19/2018 3:51:49 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow