EF6表拆分VS多个拆分共享主键 [英] EF6 Table splitting vs shared primary key for multiple splits

查看:801
本文介绍了EF6表拆分VS多个拆分共享主键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我升级旧的数据库系统到.NET +实体框架6(代号第一POCO)+ PostgreSQL的。为了便于编程,我想一个大表(200+场)分割成多个实体,例如:

I am upgrading a legacy database system into .NET + Entity Framework 6 (code-first POCO) + PostgreSQL. For ease of programming, I wish to split a large table (200+ fields) into multiple entities, eg.:

Franchise
FranchiseLegalEntity
FranchiseBilling
FranchiseSignup
FranchiseAllocation
FranchiseCompliance
FranchiseMiscellaneous
FranchiseNotifications

我很高兴地发现EF6支持表分裂:映射一个表对多个实体分割领域了。

I was delighted to find EF6 supports "table splitting": mapping a single table to multiple entities to split the fields up.

不过尝试实现这一点,和在线阅读很多页面,确认这分裂多次,当是有问题的。实体框架需要导航属性不只是主要实体,但映射到表中的所有实体之间。对于以上我的方案,这将需要21无意义的导航属性 - 42,如果我作了困扰使他们双向

However attempting to implement this, and reading many pages online, confirmed that this is problematic when splitting multiple times. Entity Framework requires navigation properties not just to the principal entity, but between ALL entities mapped to the table. For my scenario above, this would require 21 pointless navigation properties - 42 if I made bothered making them two-way.

请参阅:的 http://social.msdn.microsoft.com/Forums/en-US/0f65caae-8a66-431f-aa02-4b2c68f871e9/ef-41-rc-code-first-split-one-table-成海报实体论坛= adodotnetentityframework

请参阅:的如何大表到使用EF-代码优先

使用多个表与共享主键建议,一个是我的选择。然而,鉴于英孚的臃肿的SQL查询生成和PostgreSQL与复杂的查询,我对这个选项(100GB +数据库)的性能问题,有时随意查询优化器。

Using multiple tables with a shared primary key is recommended, an is an option for me. However, given EF's bloated SQL query generation, and PostgreSQL's sometimes haphazard query optimizer with complex queries, I have concerns about the performance of this option (100GB+ database).

要总结

表格分裂

赞成的:最佳查询性能,最快在数据库层实施

Pros: Best query performance, quickest to implement at database layer

缺点的:污染的我的模特和OnModelBuilding()方法,垃圾,混淆其他开发商

Cons: Polluting my models and OnModelBuilding() method with crap, confusing other developers

<跨多个表STRONG>共享主键

赞成的:最干净型号和放大器;代码,对于非传统的数据库推荐的解决方案

Pros: Cleanest models & code, recommended solution for non-legacy databases

缺点的:额外的工作来实现,这可能表现较差

Cons: Extra work to implement, potentially poorer performance

我的问题:

1)具有EF6提高桌子劈开2+分裂

1) Has EF6 improved the table splitting with 2+ splits?

2)是否有我没有考虑任何因素?

2) Are there any factors I haven't considered?

3)是否还有其他选择吗?

3) Are there any other options?

PS我没有兴趣使用[的ComplexType]

P.S. I am not interested in using [ComplexType]

推荐答案

我已经看中了该解决方案是表拆分选项。

The solution I have settled on is the Table Splitting option.

这涉及添加了很多无谓的导航属性对我的模型,依靠流利的API。我认为这是两害取其轻,因为它们会导致最少的开销,并避免潜在的性能问题。

This involves adding a lot of pointless navigation properties to my models and relying on fluent API. I think it's the lesser of the two evils since they cause minimal overhead, and avoid the potential performance problems.

我已经列出更详细的(包括代码)解决方案在这个线程:

I've outlined the solution in more detail (including code) in this thread:

EF6未能建立表分流/共享主键+基地级车型?

这篇关于EF6表拆分VS多个拆分共享主键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆