The EntityDataSource component enables data items to connect to an ADO.NET Entity Data Model. This allows seamless integration of Telerik Reporting with applications or web sites that utilize the ADO.NET Entity Framework. There are several main benefits when using the EntityDataSource component for connecting to an Entity Data Model:
- Dedicated design-time support: the EntityDataSource component has its own set of design-time editors, tool windows, and a configuration wizard. In addition to this, EntityDataSource adds support for entity schema in Data Explorer and live data preview of the report in Report Designer.
- Configuring database connectivity: the EntityDataSource component offers an additional level of control over the database connectivity of the Entity Data Model. You can specify a connection string or a named connection from the configuration file of the main application or web site. That ensures EntityDataSource can establish a valid database connection both at design-time and when running the report in production.
- Maintaining ObjectContext/DbContext lifecycle: the EntityDataSource component allows
the option to maintain the entire lifecycle of the ObjectContext or DbContext automatically. It can create its own
instance of one of the two contexts internally, keep it alive for the duration of the report generation process,
and then destroy it automatically when it is no longer needed by the reporting engine.
When using DbContext by default the context class generated (Database First or Model First) provides only a default (parameterless) constructor. However for design time purposes a constructor with connection string (string argument) is needed so that while processing the report the correct connection string can be passed. If Code First is used there is no need for a constructor with string parameter. That is because this approach uses connection strings without metadata (which is needed for the mapping). This means that the connection string of the context can be directly set to this connection string, without the need to be resolved first. Adding the needed constructor is as simple as it is adding the snippet below:
.NET Framework 4.0 and above