0

I'm facing a strange problem, I'm trying to run a method that explicitly migrates my database to the latest version withing EF code first, how ever when I run the method, nothing happened, heres my method that intends to migrate the database:

 public void migrate()
    {
        Database.SetInitializer(
               new MigrateDatabaseToLatestVersion<Alumnosdb, Migrations.Configuration>()
               );
    }

when I get to this method by way of debugging and hover over at Database, the connection states is closed and nothing happened.

Here is a snapshot where the problem occurs: http://s8.postimg.org/r20k94ifp/errormigrate.png

Hopefully someone can point me on how to migrate my schema by way of code cause it seems the way that I'm trying to achieve this is not working, so any advice would be really appreciate it.

1 Answer 1

1

This just sets the initializer, not runs it. It will run when you actually use DbContext session.

Sign up to request clarification or add additional context in comments.

2 Comments

You mean I have to perform some sorth of query against the dbcontext in order for the migrations to take effect? I'll try to add a basic query and see if it works.
Thank you so much, I had to perform some queries that would make dbcontext take effect so the migrations will start doing its job, thanks this is now solved.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.