Upgrade existing database after making table changes to Entity Framework edmx file

Viewed 12

I inherited an old c# project that used Entity Framework 4 to create the database. I need to add two new fields into a table, so I opened SQL Management Studio and added the new fields then ran a "Update model from database" in Visual Studio. It added my new fields.

The problem is many people have this c# program installed on their desktops with the older database (SQL Express installed on each machine locally). If I just send them an installer with this new schema, will it update their database automatically or do I need to call something in my code to update their database.

The code right now does

if (context.DatabaseExists())
{
    //database exists, load what we need
}
else
{
    context.CreateDatabase();
}

Do I need to call a context update or something if the databases don't match? Also I am worried about losing their data, I need the users existing data to still be there.

0 Answers
Related