microsoft提供的各种数据模板之间有什么区别? [英] What is the difference between that various data templates microsoft provides?

查看:100
本文介绍了microsoft提供的各种数据模板之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:这与数据库优先",模型优先"和代码优先"之间的区别无关.

Microsoft有许多工具可以简化DbContext的使用.不幸的是,似乎几乎没有描述,也没有关于它们是什么的文档,更不用说它们的作用了.

Microsoft has a number of tools to simplify using DbContext. Unfortunately, there seems to be almost no description and also no documentation on what they are, much less what they do.

两者之间有什么区别

  • Entity Framework Power Tools CTP1
  • ADO.NET C# DbContext Generator
  • ADO.NET C# POCO Entity Generator

推荐答案

我通常不回答自己的问题,但这是我想出的答案:

I don't usually answer my own questions, but here is what I figured out:

ADO.NET C# DbContext GeneratorADO.NET C# POCO Entity Generator之间的区别在于,前者基于DbContext创建上下文,而后者基于ObjectContext创建它们.

The difference between the ADO.NET C# DbContext Generator and the ADO.NET C# POCO Entity Generator is that the former creates a context based on the DbContext and the latter creates them based on the ObjectContext.

基本上,它们在Model FirstDatabase First方法中使用. Model FirstDatabase First之间的区别在于,在Database First中,您在数据库中定义数据模型,然后从数据库中对模型进行反向工程(即创建.edmx文件).使用Model First时,您可以在设计器中(同样是.edmx文件)或手动创建模型,然后从该模型生成数据库.

Basically, these are used in the Model First and Database First approaches. The difference between Model First and Database First is that in Database First, you define your data model in the database, then reverse engineer the model (ie. create an .edmx file) from the database. While with Model First, you create your model in the designer (again, the .edmx file) or by hand, then generate the database from that model.

在两种情况下,您都可以从.edmx文件中生成POCO类以及DbContextObjectContext.

In both cases, you then generate POCO classes and either a DbContext or ObjectContext from the .edmx file.

Entity Framework Power Tools CTP1对数据库中的Code First模型进行逆向工程,包括POCO类,DbContext(认为它不提供ObjectContext生成)和映射(通过OnModelCreating方法).

The Entity Framework Power Tools CTP1 reverse engineers a Code First model from the database, including POCO class, the DbContext (don't think it offers ObjectContext generation) and the mappings (via the OnModelCreating method).

所以这可以归结为在Database FirstModel First中,模型"由xml .edmx文件(或在某些情况下为多个文件)定义.在Code First中时,使用OnModelCreating中的流利代码映射定义模型.

So what this boils down to is that in Database First and Model First, the "model" is defined by the xml .edmx file (or in some cases, several files). While in Code First, the model is defined using fluent code mappings in OnModelCreating.

使用Power Tools进行数据库反向工程时,它不会创建.edmx文件,而是在代码中创建映射.因此,跳过xml中间人.

When using the Power Tools to reverse engineer the database, it doesn't create an .edmx file, instead creating the mappings in code. Thus, skipping the xml middle man.

这篇关于microsoft提供的各种数据模板之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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