Data Access has been discontinued. Please refer to this page for more information.

How to: Use Multiple Models With Aggregated MetadataContainer

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

Let's look at a scenario where the data access layer of the application consist of two models based on the AdventureWors sample database. The GeneralSchema.rlinq file represents the default schema and the PersonSchema.rlinq file represents the Person schema (Figure 1: GeneralSchema.rlinq And PersonSchema.rlinq).

Figure 1: GeneralSchema.rlinq And PersonSchema.rlinq

In order for you to be able to use the Multiple Models With The Same Connection String support for Multiple Models With Aggregated MetadataContainer you need to make sure that both domain models are in the same namespace (Figure 2: GeneralSchema.rlinq And PersonSchema.rlinq Properties).

Figure 2: GeneralSchema.rlinq And PersonSchema.rlinq Properties

There are a few important details you need to consider in this scenario:

  • Telerik Data Access will aggregate the metadata for the models based on the connection string provided in the .config file. In other words, if the two models use connection strings that point to one and the same database but are syntactically different, Telerik Data Access will not aggregate the metadata. Rather than that, the scenario will be Multiple Models With Separate MetadataContainer Instances.
  • Once Telerik Data Access aggregates the metadata of the two models, the result is preserved in a new MetadataContainer and all types of cache will be purged. At that point, if a context for one of the models is instantiated, it will use the aggregated metadata without any further operations.
  • If the object that holds the aggregated metadata is disposed, the next time a context with the provided connection string is instantiated the aggregation procedure will start again.