I just enabled migrations in my project and added a few fields to UserProfile
:
[Table(\"UserProfile\")]
public class UserProfile
{
[Key]
are you sure you're looking at the right Db?
it seems so though. Did you get any errors? Any special permissions etc.
My advice is to create a new connection - e.g. config and
<connectionStrings>
<add name="HifiContext" connectionString="Data Source=MACHINE\INSTANCE;Initial Catalog=HiFi;Integrated Security=True; MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
</connectionStrings>`
...and backup your old just in case. i.e. recreate Db from scratch
If nothing works - try recreating if you just turned migrations on - no other ideas.
As for why the out-of-sync happened - hard to say for sure - but I'm guessing you had 'two connection strings' as well (or at some level).
Make sure that you connection string is 'named' the same as your
dbcontext
- or put connection at your at DbContext directly
. It is sometimes a problem, as it's not apparent what the EF/CF 'makes' as its default.
call this method in your startup code to have the database recreated with the new fields:
public void CheckForDBChanes()
{
Database.SetInitializer(new DropCreateDatabaseIfModelChanges<Context>());
}