1
In my ASP.net MVC5 project he creates the default database by Visual Studio 2013.
I went to the App_data folder and deleted the database mdf file, as well as the log file.
I’m wanting him to create that file again.
In my configuration file, I have the following code.
public class UserDBContext: DbContext
{
public UserDBContext(): base("ConnectionString")
{
Database.SetInitializer<UserDBContext>(new CreateDatabaseIfNotExists<UserDBContext>());
}
public DbSet<Cliente> Clientes{ get; set; }
public DbSet<Topico> Topicos{ get; set; }
}
It passes, and does not give any error, however it does not create database file.
Do you have any code that uses the context class, accessing the
DbSet
s? The RU uses a strategy of Lazy Evaluation which only executes the code when needed.– carlosfigueira