Is there an ORM that allows a "plugin" to extend the database?
So, I've been searching for the answer to this, but I can't find anything
I have an Entity Framework Model (MyModel1) - for now, we'll say this contains a "Users" table
It's part of a big app, that has a references to an "Addresses" project
The addresses project contains an Entity Framework Model (MyModel2), t开发者_Python百科his contains a Users table, and an Addresses table (pointing to the same database.
The main app has a control that edits the user, and in that control it has an "addresses" control which actually exists in the "Addresses" project.
To make this work, the User control passes the User object down to the addresses control, however, as the User that's been passed belongs to MyModel1 and not MyModel2, another User object has to be loaded up, then it can be used.
This isn't ideal as I've had to load up the User twice. Is there a way of say, MyModel2 extending MyModel1, which effectively just adds a relationship to "User". Or is there an ORM that would handle this better? Or even a design pattern that would handle this better?
I discovered Fluent NHibernate which seems to give me a load more control over how the data layer is put together, through some seriously crazy code I was able to extend the entities in a plugin kind of way, very cool
It sounds like today you have a projects that are a mixture of UI, business logic and data access logic.
A better approach would be to put your Data Access layer into a single project separate from the business logic and the UI. Create an EDMX that includes both Users and Addresses and provide a single ObjectContext that can be used to handle the whole process.
Take a look at the Repository pattern too.
精彩评论