使用 DB First 与 Code First 的优点/缺点是什么?
我知道 enum
目前仅在 2011 年 6 月的 CTP 中可用,并且不会在 4.2 中提供。还有什么其他因素会让人们选择其中之一?
I know enum
s are currently only available in the June 2011 CTP and won't be in 4.2. What other factors would make someone choose one or the other?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Ladislav Mrnka 有一个很棒的答案 打破了 DB First、Code First 和 Model First 之间的差异。我强烈建议您阅读并投票。
除此之外,我仅补充以下几点:
即使在 2011 年 6 月的 CTP 中,Enum 支持也是有限的,因此您可能更新:EF5+ 支持使用 EF 设计器的枚举 和 代码优先。想看看这些问题是否对您来说是个难题。
如果您正在针对 Oracle DB 实施 EF,并且您
不想为数据提供商付费,那么您将
没有 Code First,作为 Oracle 的自己的提供商
(仍处于测试阶段)不支持它。
编辑:这是拉迪斯拉夫的另一个全面的答案。
Ladislav Mrnka has a great SO answer that breaks down the differences between DB First, Code First and Model First. I strongly suggest that you go read it and upvote it.
Besides that, I would only add the following points:
Even in the June 2011 CTP, Enum support is limited, so you mightUpdate: EF5+ supports Enums with EF Designer and Code First.want to see if any of those issues are showstoppers for you.
If you are implementing EF against an Oracle DB, and you
don't want to pay for a data provider, then you will be
without Code First, as Oracle's own provider
(still in beta)doesn't support it.
Edit: here is another comprehensive answer from Ladislav.
请参阅实体框架开发方法
http://www.asp.net/entity-framework/tutorials/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application
See Entity Framework Development Approaches in
http://www.asp.net/entity-framework/tutorials/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application
优点:适用于所有对象查询(无论是否是数据库)的通用语法(LINQ / Yoda),如果按预期使用,速度相当快,易于实现 SoC,完成复杂任务所需的编码较少
缺点:你必须以非传统的方式来处理数据,并非适用于每个数据库
缺点:如果数据库中有任何架构更改,FE 将不起作用!您还必须更新解决方案中的架构!
优点:使用 LINQ/FE 对象进行添加/修改/删除/更新快速且直接。
优点:-易于映射业务对象(通过在环境中拖放表格)。
- 当您使用小/中域模型时,它保持良好的性能。
缺点:-当您使用巨大的域模型时,它会受到限制。
-可扩展性。
Advantages : One common syntax ( LINQ / Yoda ) for all object queries whether it is database or not , Pretty fast if used as intended , easy to implement SoC , less coding required to accomplish complex tasks
Disadvantages : you have to think in a non traditional way of handling data , not available for every database
Disadvantage: If there is any schema change in database FE won’t work!!! You have to update the schema in solution as well!!!
Advantage: Its fast and straight forward using LINQ/FE objects For Add/Modify/Delete/Update.
Advantages:-Easy to map business objects (with drag & drop tables on environment).
-It keeps a good performance when you work with a small / middle domain model.
Disadvantages:-It's limited when you work with a huge domain model.
-Scalability.