I add the same table in a limited environment context with multiple entities

I have a fairly large database, about 80 tables. Therefore, I decided to divide the tables into a limited context instead of having all 80 tables in 1 large edmx file.

So, I have limited contexts like Sales, Customers, etc.

I have my main client table in my clients edmx file. However, I also need to access certain fields, but not 1 or 2 fields (for example, I just need the customer name, not the entire client object / table) from the customer table from the Sales edmx context.

Do I need to add the entire customer table to my edmx Sales file? What is the best practice for this scenario?

+5
source share
3 answers

There are several major issues (IMOs) in this approach:

EF, like any ORM, relates to the issue of persistence. Thus, this should not interfere with how you structure your domain model. The fact that all of your entities are stored in what sounds like one store of preservation may be a sign that your limited contexts overlap or are missing.

Trying to move to a better structure is not bad :) --- however, as Mark Oreta stated, I probably would not have bothered with the structure of EF.

, , . , , , . - - . , ( ), . . . , , , .

, .

, , . ( ) / ( .NET). . . , . , BC . - , , , .

, BCs , , , :)

+5

http://msdn.microsoft.com/en-us/magazine/jj883952.aspx

, dbcontext . . MS ef: http://msdn.microsoft.com/en-us/data/hh949853

BC , -. , db, , DBSet, . , EF .

SUPERSET / . .

DBcontexts .

, , , . SAME. ", ( DbSet) .

+8

If you want to access the Customer object from your Sales object using the navigation property, ( Sale.Customer), you need to add it to sales edmx.

It is not necessary to have all your tables in one edmx, while you create it, use it for the actions you want, and then get rid of it, the object graph will not get this big.

Alternatively, if you want to keep limited contexts, you can have a repository or something by identifier when you need it.

var customer = customerContext.GetCustomerById(sale.CustomerId);
+2
source

All Articles