使用“在模型中包含外键列” EF 向导中的选项
您主要使用此选项(默认选中)还是取消选中它?
我发现,当我的实体上同时具有 FK 列和导航属性时,会导致映射工具出现问题 - 它们可能会绑定其中之一,但几乎不会同时绑定两者。
如果我们严格遵循概念模型的指导方针,我认为这些列永远不应该成为属性,不是吗?
希望你们中的许多人能够回复,以便我们能够更好地了解开发人员更频繁地选择的内容。
Do you mostly use this option (the default is checked) or do you uncheck it?
I found out that when I have both FK column and navigation property on my entities it results in problems with mapping tools - they might bind one or the other but almost never both.
If we were to follow the guidelines of conceptual models strictly I think those columns should never make it to properties, should they?
Hopefully many of you reply so we can get a better representation of what developers choose more often.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的 - 这就是 EF 团队在 .NET 3.5 SP1 的第一个版本中所做的 - 并得到了大量非常负面的反馈。
是的,“纯粹”地说 - 您不应该直接使用外键列 - 您应该使用正确的方法来处理引用的实体。但实际上,在许多情况下 - 您实际上不想处理整个引用的实体 - 只需设置外键列即可(例如,在导入数据或许多其他情况下)。
因此,虽然是的 - 我同意 - 有时有点麻烦,但我确实认为它是一个很大的优点,您可以选择在实体中使用外键列 - 毕竟,在数据库级别,这就是您所要做的也会处理。
因此,在我看来,以及我从也在认真工作中使用 EF 的同事以及所有博主和 EF 专家(例如撰写关于 EF 的书的 Julie Lerman)那里听到的所有建议 -打开该选项,您将获得两全其美的效果!
Right - that's what the EF team did in the first release with .NET 3.5 SP1 - and got a ton of very negative feedback on it.
Yes, "puristically" speaking - you shouldn't be using foreign key columns directly - you should use the proper way of dealing with the referenced entity instead. But in reality, in many cases - you don't want to have to deal with the whole referenced entity, really - just setting the foreign key column will do (e.g. when importing data or many other cases).
So while yes - I agree - it's a bit of a hack at times, I do see it as a big plus that you have the option to use the foreign key column in an entity - after all, at the database level, that's what you'll be dealing with, too.
So in my opinion, and all the recommendations I've heard from colleagues who also use EF in serious work and all the blogger and EF gurus out there (like Julie Lerman who wrote the book on EF) - turn on that option, and you get the best of both worlds!