I'm trying to ignore the "Automatic" migration using Entity Framework 6.0 rc1. My problem is that I don't want this feature right now and every time that my application runs I can see all entity logs trying to create all tables.
Anticipate thanks.
I'm trying to ignore the "Automatic" migration using Entity Framework 6.0 rc1. My problem is that I don't want this feature right now and every time that my application runs I can see all entity logs trying to create all tables.
Anticipate thanks.
You can put this inside your entityFramework section of the app.config:
This msdn page tells all about the Entity Framework Configuration Section.
Via web.config see - https://msdn.microsoft.com/en-us/data/jj556606.aspx#Initializers
Via Code (oddly, MUCH simpler answer)
or in Global.asax.cs
If you found this question hoping for a simple answer to disable migrations because you typed "Enable-Migrations" and now things aren't working the way you expected, like not running the seed method you thought it would run, then look in the solution explorer and delete the Migrations folder. That will stop the code from looking at the migrations config to find initialization code. To get the Migrations folder back, just run "Enable-Migrations" again.
The mistake I was making was to call Database.SetInitializer(null); too late (after the context had been initialised). The best way to ensure migrations are disabled is to make the above call for all your contexts in your application startup. I favor this approach over setting it in the app.config so I can use my container to locate my contexts and then construct a call.
Disabling the automatic migration can also be configured during the invoke of the
enable-migrations
command (which creates theConfiguration
class), using theEnableAutomaticMigration
parameter with a value offalse
:The will create a
Configuration
class which sets theAutomaticMigrationsEnabled
property to false, like in the answer above.The
EnableAutomaticMigration
parameter of theenable-migrations
command is mentioned in this article of the Entity Framework Tutorial page (however they use it withtrue
which seems to be the default value).Try this:
UPDATE:
You can also try this: