Entity Framework cross-Context Query

Source: Internet
Author: User
Tags xml parser

Transferred from Andrew's blog to the Entity Framework-query across Context

Http://columns.chicken-house.net/post/e99ba3e6909ee79a84-Entity-Framework-e8b7a8e8b68a-Context-e79a84e69fa5e8a9a2.aspx

 

First of all, I would like to express my gratitude to the author. below is the text, and I hope he can help you.

 

Cough, No thanks... nothing has been done in the past two months, that is, they are studying Entity Framework and Enterprise Library... enterprise Library is better. Let's take a look at the example and check whether the key scenario can be imported into the repository. However, the Entity Framework does not have such a ticket...

M $ has a large rule on the roadmap of Entity Framework, but it is only the first version that is attached to. Net 3.5 SP1. Backed by a large architecture, it is hard to work out other mature ORM solutions.

First, let's complain about its design tool... it's easy to use (compared with directly using XML Parser), but there are still a lot of small issues. For example, if the table is pulled in and pulled out, the build will fail... if the view is pulled in, the specified key cannot be exactly the specified location. If the result is incorrect, the build fails, and you cannot help but manually modify the key. edmx .. in fact, these events have touched a lot in the past two months @_@

However, the design of the Entity Framework is not enough. The rest of my experiences will be solved again in the next day. I am stuck with the longest problem, which is also a common problem of most ORM-the problem of large databases.

This refers to "large" not to the fact that there are many data records, but to the situation where the schema is very informative. It is common for large AP instances to use hundreds of tables and views. Especially when the revision is completed, the new table is not deleted, and the new table is continuously added. All ORM systems require the O/R Mapping of a certain type of topology. They are either preset or Visualized Design tools. But... can you imagine a ER-MODEL with 500 tables?

To avoid a large single or mapping setting, we only need to cut the degree of parallelism. In Entity Framework/Visual Studio 2008, this can be easily done by dividing it into multiple. edmx instances. However, there will be several. edmx missing points in the backend:

    1. There will be multiple objectcontext products. Each region has objects to be updated, and each objectcontext has to call savechange ..
    2. Regardless of whether it is LINQ to entities or esql. If you want to join multiple objects across multiple. edmx resources, you will get an emotional response... cross-context operations are not supported.
    3. Assoicationset cannot span the metadata of the context, which means that the entity of the Cross-. edmx cannot be handled by navigation property.

There are also solutions, and we also checked the ADO. Net team blog. These two articles are related to all Google websites.ArticleHere, the most in-depth explanation of this issue ..

    • Working with large models in Entity Framework-Part 1
    • Working with large models in Entity Framework-Part 2

You must take a look at these two questions. In fact, the questions discussed in this article have already exceeded my needs. I just want to solve the problems I have encountered:

    1. Due to the needs of the application model, I need to seal the zookeeper related to. edmx in different assemblies.
    2. Entityset with different modulo definitions can perform join query using esql.
    3. The most basic LINQ is not enough.
    4. When a new model group is added, other models do not need to be renewed again.

I honestly said that these two articles did not solve my problem, but I only caught sight of some of the words in Part 2:

9. at runtime, you can create either one context that works with the both the schema sets or two different contexts. to create a single context with both the schema sets, you wocould use the objectcontext constructor that takes in an entityconnectionstring. in the metadata parameter of the connection string, specify the paths to both sets of files.

Haha, I'm not lucky. I haven't missed a period of time when I was concerned... it solved my troubles for more than a month. The token string used by entity connection is smelly and long, including your. CSDL ,. SSDL ,. the three definitions of MSL are there, and the database connection string is used for the baseline. the following is a string:

Medadata = Res: // */model1.csdl | res: // */model1.ssdl | res: // */model1.msl ;............

From these two articles, apart from the various split/reuse methods and missing points for the heap setting, it is learned that the original entity connect string can be written into multiple groups of response Ah: D, like this:

Medadata = Res: // */model1.csdl | res: // */model1.ssdl | res: // */model1.msl | res: // */model2.csdl | res: // */model2.ssdl | res: // */model2.msl ;............

No !! If it is not worth the money, it is enough to change the entity connection string so that esql can access two copies through a single object context. for the content defined in edmx, you must use the createquery () method to generate entityset .. nothing else is too big.

Solve this problem !! Close! Other applications will be available in the next day. I am sorry that you have not canceled posting my blog during the dry season of the past two months...

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.