The Entity Framework ObjectContext allows for development using a model automatically generated by a Visual Studio designer. However, when deployed within DotNetNuke, these attributes do not pick up the database owner and object qualifier required for correct inter-operation. Because of this, large-scale deployment of modules using the Entity Framework is infeasible, and modules using the technology are unfortunately limited to internal applications.
To remedy this issue, I have developed an adapter that converts the Entity Framework model generated by the designer into a DotNetNuke-compatible model that uses both the object qualifier and database owner specified by an end-installation. This adapter is based off of the more generalized model adaptation framework that I recently released.
My goals for any satisfactory solution were as follows:
- Run-time adjustment of an Entity Framework EDMX model to conform to any given DotNetNuke installation, including:
- Connection-based adaptation (e.g. use of a runtime-specified connection string)
- Run-time adjustment of model schema to effectuate:
- Adjusting data-level table and stored procedure prefixes to match the DotNetNuke installation ObjectQualifier
- Adjusting the owner of database objects to match the DotNetNuke installation DatabaseOwner
- Continued use of the Visual Studio Model designer
- No tedious changes in the compiler-generated code
- Continued use of an assembly-embedded EDMX model (and thereby no additional or external schema deployment files)
This solution extends the Entity Framework runtime model adapter to operate within a DotNetNuke extension, allowing a developer to design against an unqualified, dbo-owned DotNetNuke instance and be assured that it will deploy (and operate) correctly on any configuration that an end user might have deployed. Adaptation is largely inexpensive, and since the models are cached by type, performance is not significantly affected.
Click here to access the project site for additional details and downloads. Though the content herein is protected under the license below, be sure to consult the project license (New BSD) for integration-related details.
As always, feedback is greatly appreciated.
The Released: DotNetNuke Entity Framework Model Adapter by Brandon Haynes, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.