Click here to Skip to main content
15,880,405 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
hi to all,


How to disable Migration entity framework bcz in my project database is automatically created for given datacontext name so kindly send me code how to disable Migration and refer my own database in my table



my mail address:- [email removed]
Posted
Updated 6-Jul-21 8:45am
v2
Comments
johannesnestler 3-Jul-14 9:13am    
please don't post your email address here - I removed it from your question, you will get answers here and also get informed via mail about posted solutions.
To your question: Do you even want to use code first? If not you can "turn off" database generation with Database.SetInitializer<yourdbcontext>(null);
JOTHI KUMAR Member 10918227 3-Jul-14 9:20am    
thanks for reply me
send full disable code for me
johannesnestler 3-Jul-14 13:04pm    
please see my solution

So the question seems to be how to completly disable database creation through EntityFramework.

The easiest is to disable the initializer by Setting it null for a given context type.

C#
Database.SetInitializer<YourContext>(null);


An easy Approach could be to place this code in a static constructor of your derived context.

Is this what you was looking for?

Kind regards

Johannes
 
Share this answer
 

You need to :




  1. Delete the state: Delete the migrations folder in your project; And
  2. Delete the __MigrationHistory table in your database (may be under system tables); Then
  3. Run the following command in the Package Manager Console:



    Enable-Migrations -EnableAutomaticMigrations -Force


    Use with or without -EnableAutomaticMigrations

    And finally, you can run:

    Add-Migration Initial


    Source :- Reset Entity-Framework Migrations - Stack Overflow[^]
 
Share this answer
 
v2
Don't forget to run:

C#
update-database
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900