[英]How do I create database using entity framework 6 datacontext?
I am trying to understand the code-first approach : http://blog.logiticks.com/an-absolute-beginner-s-tutorial-for-understanding-entity-framework-s-database-first-model-first-and-code-first-approaches/ 我试图理解代码优先的方法: http : //blog.logiticks.com/an-absolute-beginner-s-tutorial-for-understanding-entity-framework-s-database-first-model-first-and -code先方法/
I create the classes, then I don't know where to add the datacontext file? 我创建了类,然后我不知道将datacontext文件添加到哪里? Note that I put my classes in models folder so should i put the context file there too?
请注意,我将我的课程放在models文件夹中,所以我也应该将上下文文件放在那里吗? and how would the project understand where the context file is and create the database from there?
项目将如何理解上下文文件在哪里并从那里创建数据库? I am new to entity framework, any help is appreciated
我是实体框架的新手,感谢您的帮助
In EF database is created automatically, at least using Code First approach. 在EF中,至少使用Code First方法自动创建数据库。 When your application hits the context, EF will check and ensure that DB exists and is compatible with your model(OK, I have simplified this, but overall it is true).
当您的应用程序到达上下文时,EF将检查并确保数据库存在并且与您的模型兼容(好的,我已经简化了这个过程,但是总体来说是正确的)。
As someone in comments suggested, this tutorial doesn't seem like a viable source of knowledge. 正如有评论的人建议的那样,本教程似乎不是可行的知识来源。 I strongly encourage you to read eg this article.
我强烈建议您阅读这篇文章。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.