What are the pros and cons of the option "include external columns in the model" in EF 4

EF4 introduces a new feature, “Include Foreign Key Columns in the Model”. What was the motivation for adding this function, and is there any specific problem with its termination or inclusion when creating a model from an existing database?

+3
source share
1 answer

Not knowing the true motivation for this, I think that the value of having these extra columns arises when you expose your entities over web services or directly to a presentation level that I personally don’t refer to or recommend.

Consider the following examples.

, . , , , FK.

        var product = new Product
        {
           Category = new Category {Id = 1},
           Name = "Product 1"
        };

Entity Framework , .

        var product = new Product();
        product.Name = "Product 1";
        product.CategoryReference = new EntityReference<Category>();
        product.CategoryReference.SetEntityKey<Category>(1); 

, , .

        var product = new Product
        {
            CategoryId = 1,
            Name = "Product 1"
        };

Pros

, .

DDD, Entity.

+2

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


All Articles