How do you update an edmx file with database changes?

Updating an EDMX the safe way: As you have found, the update from database does not always change existing properties correctly. From our day-to-day use of EDMX updating (100s of updates over 24 months), I would recommend the following sequence for updating an EDMX. Delete existing model and then update: Open the EDMX designer Ctrl-A … Read more

Create a Dropdown List for MVC3 using Entity Framework (.edmx Model) & Razor Views && Insert A Database Record to Multiple Tables

Don’t pass db models directly to your views. You’re lucky enough to be using MVC, so encapsulate using view models. Create a view model class like this: public class EmployeeAddViewModel { public Employee employee { get; set; } public Dictionary<int, string> staffTypes { get; set; } // really? a 1-to-many for genders public Dictionary<int, string> … Read more

Error: “The specified LINQ expression contains references to queries that are associated with different contexts”

You’ll have to perform two database queries: var IDs = (from a in db1.Table1 join b in db1.Table2 on a.Id equals b.Id orderby a.Status where b.Id == 1 && a.Status == “new” select new a.Id).ToArray(); var query = from c in db2.Company join a in IDs on c.Id equals a.Id select new { Id = … Read more