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

How to: Use Multiple Models With Aggregated MetadataContainer

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 folder contains a model of the default schema and the PersonSchema folder contains a model of the Person schema (Figure 1: GeneralSchema And PersonSchema).

Figure 1: GeneralSchema And PersonSchema

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 models are in the same namespace (the context classes, the metadatasource clasess, and the persistent classes).

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.