Entity framework does not create mdf file

1

In my ASP.net MVC5 project it creates the default database by Visual Studio 2013.

I went to the App_Data folder and deleted the mdf file from the database as well as the log file.

I'm wanting it to re-create this file.

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 the database file.

    
asked by anonymous 27.05.2014 / 18:39

1 answer

3

To re-create the MDF, right-click on the project > Add > New Item, and choose the Service-Based Database or Service-Based Database option:

Migrations should work normally. Just run that the tables are recreated inside your file. Do not forget to update your Connection String .

    
27.05.2014 / 18:55