我们应该在MVC中使用数据库First,Code First,Model First [英] Which approach should we use database First , Code First ,Model First in MVC

查看:102
本文介绍了我们应该在MVC中使用数据库First,Code First,Model First的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们是MVC的新手

我们在更短的时间内在MVC中创建小型原型。在这个数据库中,可能会不断发生变化。因此,我们应该使用实体数据库第一模型或代码优先模型或模型?我们可以使用混合类型(数据库和代码优先)来实现结果吗?

提前谢谢.....

We are new in MVC
We are creating small prototype in MVC in less time.In this database changes may occur continuously .So which model should we use entity database first model or code first or model?Can we use mix type(Database and Code first) to achieve the result?
Thanks in advance.....

推荐答案

代码的优势首先在于对数据库的更改将更加容易和快捷......但是每次更新架构时,您将丢失表中的任何数据。如果这是一个问题,您可能需要考虑先做代码。您可以编写在重新创建数据库时自动注入数据的例程,但这显然需要额外注意。



如果有可能原型将成为真实的东西,然后由于上述原因,你会首先想要数据库。您可以从代码优先更改为数据库优先,因此它不是世界末日,但是需要考虑额外的工作。



所以,如果它真的是一个原型然后代码可能是最好的。
The advantage of code first is that the changes to your database will be much easier and quicker...however you'll lose whatever data is in your tables every time you update your schema. If this is an issue you might want to think about doing code first. You can write routines that automatically inject data when the db is re-created, but that's obviously additional effort to bear in mind.

If there is a chance that "the prototype" is going to become "the real thing", then you'll want database first for the reasons above. You can change from code-first to db-first so it's not the end of the world, but again it's additional work to think about.

So if it's genuinely a prototype then code first is probably best.


首先,您使用的是什么数据库技术... SQL Server,Oracle,Azure,Access,NoSQL,Hadoop? 。其次,数据库提供了哪些数据。在开始使用MVC和Entity Framework之前你应该知道这些事情(它不是数据库,但实际上是ADO的ORM包装器)
First of all, what database technology are you using...SQL Server, Oracle, Azure, Access,NoSQL,Hadoop ? . Secondly what data does the database provide. You should know these things before you even start on MVC and Entity Framework (which is not a database but essentially an ORM wrapper for ADO)


这篇关于我们应该在MVC中使用数据库First,Code First,Model First的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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