Processing lookup tables in Entity Framework v1

I'm just starting to work with the Microsoft Entity Framework, using it for the MVC project, since MS seems to really push it, and I'm having some problems. In my database there are several lookup tables linked to one table through foreign keys. As part of an entity, I'm trying to combine them into one so that I have a simplified single view for this data in my model. However, this is not possible from the design presentation. Is there something obvious that I'm missing? Is there a way I can edit the edmx file manually to create such a model?

+3
source share
1 answer

Currently, foreign keys and lookup tables in the Entity Framework are PAIN.

EF with LINQ makes your data super-light, and on the surface it is easily updated, but with the help of lookup tables everything becomes complicated (at the moment ... read more ...)

I'm not sure how you “merge” your search tables into one table. If each table contains a different type of "lookup entity", then IMHO they must be presented separately in your EDM. I assume that you have headaches updating foreign keys of record in search tables. This is because it is a headache.

Change foreign key values:

MyDBEntities _db = new MyDBEntities();
//get a Person
MyDBEntities.Person person = (from p in _db.Persons
                      where p.Id = 1
                      select p).First();
// This sets the foreign key value in the Person table on the PersonType field
person.PersonTypeReference = new EntityKey("MyDBEntities.PersonType", "PersonTypeId", 3) 

Entity Framework " FK". , EntityKey.

.

+3

Source: https://habr.com/ru/post/1709331/


All Articles