0

I have been tasked with designing a data access layer that will connect to tables with interchangable schemas(used for permissions and separation). The database itself may different each call as well (because of business rules). I plan on using Entity Framework 4.3(all existing apps that will use this are already using Entity Framework) with POCO classes (to prevent multiple dev's from accidently using the model generator against something that's customized) and DbContext (so effectively Compact Framework without the code generating). I plan on utilizing DbModelBuilder and EntityConnectionStringBuilder to achieve these dynamic situations. Anyone done this or have a better solution?

4

1 回答 1

0

Visual Studio 有一些扩展,可以使用 t4 模板自动生成 POCO。还有用于自动生成存储库和相关接口的 T4 模板。这些选项还能够添加使使用 WCF 更容易的选项。这是视觉工作室扩展链接。

http://visualstudiogallery.msdn.microsoft.com/ff781f46-d8c3-45e0-a545-40906921bb86

如果 .edmx 位于同一命名空间中,此扩展会自动更新 poco 类。更改名称空间或项目并将 poco 分离为与 DAL 分离的项目的选项是可以实现的,但您必须告诉 poco 寻找更改。

我希望这能回答你的问题。不是这样,我可以通过一些额外的上下文再次尝试它。

于 2012-06-04T18:15:59.343 回答