在Visual Studio中添加新数据项时EF 6.x DbContext Generator选项的用途 [英] Purpose of EF 6.x DbContext Generator option when adding a new data item in Visual Studio

查看:354
本文介绍了在Visual Studio中添加新数据项时EF 6.x DbContext Generator选项的用途的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用LINQ to SQL构建的Web应用程序,我希望将其升级到LINQ to Entity Framework.我看了一些教程,据了解,基本上是在数据库优先场景中,您创建了一个ADO.NET实体数据模型.然后从那里选择要包含在模型中的表(非常类似于LINQ to SQL).

I have a web app that I built using LINQ to SQL and I'm looking to upgrade it to LINQ to Entity Framework. I've looked at some tutorials and what I've learned is that basically in the database-first scenario, you create an ADO.NET Entity Data Model. And from there, you select which tables to include in the model (very similar to LINQ to SQL).

添加新项对话框中,我看到还有另一个选项可以创建 EF 6.x DbContext Generator :

Within the Add New Item dialog, I see that there is another option that creates an EF 6.x DbContext Generator:

ADO.NET实体数据模型(对话框中的第一个选项)相比, EF 6.x DbContext Generator 的目的是什么?而且, EF 6.x DbContext Generator 的用途是什么?似乎创建了一个文本文件.我该怎么办?

What is the purpose of EF 6.x DbContext Generator compared to ADO.NET Entity Data Model (first option in dialog)? And, what is EF 6.x DbContext Generator for? It seems to create a text file. What should I do with it?

推荐答案

如果您已经有一个数据库,则第一种选择更好,因为该方法与您正在LinqToSQL中使用的方法非常相似. .EDMX文件还可以为您提供数据库的图形化可视化,并且您无需担心其他任何事情.

If you already have a database, the first option is better, given that the approach is very similar to the one you are already working in LinqToSQL. The .EDMX file also can provide you a graphical visualization of your database, and you don't have to worry about anything else.

这篇关于在Visual Studio中添加新数据项时EF 6.x DbContext Generator选项的用途的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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