I am building a solution with the following Projects:
Main.Data
- Class Library project
Main.API
- Asp.NET MVC WebApi - references Main.Data
Main
- Asp.NET MVC 4 web application - references Main.API
I have a MyContext : DbContext
class located inside Main.Data
project.
I have also successfully issues enable-migrations
console command on Main.Data
project, and I am successfully using LocalDB as an SQL server for my data and for upgrade-database
migrations.
The problem starts when I am trying to publish Main
project to Windows Azure website.
The Publish Profile that is automatically created using Import from a Windows Azure web site
does not seems to recognize that I am using Entity Framework Code First solution, and so I can't enable Execute Code First Migrations
as I would like to.
Instead, I can only enable Update database
scripts.
I am using Visual Studio 2012 with Entity Framework 5.0.0 (Since the beginning of the project).
Just to verify, I have tried to add a temporary MyContext
class inside the Main
Project and to enable-migrations
on the Main
project, and after that my Publish Profile automatically detected Entity Framework Code-First.
That is, of-course, not a solution (or is it?)
Here are some relevant threads:
- This is the base learning tutorial.
- This explains deployment options, but no troubleshooting.
- This actually gives a few ideas to try, but all seems unnatural.
I am looking for a clean stable solution. Do I have to put my Context class inside the Main Project?
Thanks in advance
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…