简体   繁体   English

ASP.NET MVC3数据库创建

[英]ASP.NET MVC3 database creation

So, I am in class and we create the database the good ol fashioned way by logging into the database via a host and running sql commands to create table blah blah blah. 因此,我在上课,我们通过主机登录数据库并运行sql命令以创建表等等来以良好的方式创建数据库。 This is the way I am used to coming from the php side of things with simple web sites. 这是我习惯从简单网站的php端获取信息的方式。

Then I ran into the tutorials ( http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-model ) that use DBContext to generate the db structure via I believe scaffolding. 然后,我遇到了使用DBContext通过我相信生成db结构的教程( http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-model )脚手架。 Is this a new feature that we are expected to use as part of that framework? 这是我们期望用作该框架一部分的新功能吗? Or is it not a best practice to use this feature. 还是使用此功能不是最佳实践。 Security vs. Functionality what are the pros/cons of each if any. 安全性与功能性(如果有)的优点/缺点是什么? Thanks guys. 多谢你们。

Well, how do you like the idea of not having to ever really care if you have a database? 好吧,您是否喜欢不必真正关心数据库的想法? Do you like writing a data access layer or would you rather create your class and let the MVC framework worry about how to persist it? 您是喜欢编写数据访问层还是创建类并让MVC框架担心如何持久化它?

I think there are pros and cons to each approach. 我认为每种方法都各有利弊。 Some of the auto-generated database stuff can be a little kludgy and I personally enjoy creating databases anyway. 自动生成的一些数据库内容可能有点笨拙,我个人还是很喜欢创建数据库。

Here's an article that might help: 这是一篇可能有帮助的文章:

http://msdn.microsoft.com/en-us/data/gg685489.aspx http://msdn.microsoft.com/en-us/data/gg685489.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM