“数据库优先”或“模型优先”? [英] "Database First" or "Model First"?

查看:115
本文介绍了“数据库优先”或“模型优先”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解使用实体框架有三种可能的方式 -  

I understand there are three possible ways of using the Entity Framework - 

1。数据库优先

2.模型优先

3.代码优先(CTP4)

1. Database First
2. Model First
3. Code First (CTP4)

如果我有一个现有的SQL数据库但是我创建了基于该现有SQL数据库的我的模型(.EDMX文件)是这个"数据库优先"数据库。或者"模型优先"。

If I have an existing SQL database but I create my model (.EDMX file) based on this existing SQL database, is this "Database First" or "Model First".

我对模型所做的更改类型是将两个表中的字段映射到一个实体或将字段从一个表映射到两个实体等等...

The type of changes I'd make to the model are mapping fields from two tables into one entity or mapping fields from one table into two entities, etc...

推荐答案

嗨Emmanuel,

Hi Emmanuel,

这样做不是他们中的任何一个。如果我在哪里贴标签,我会称之为浪费时间。 :) 

Doing in that way is not any of them. If I where to label it I would call it a waste of time. :)  

如果您已经拥有SQL数据库,那么当您可以根据数据库快速为您自动生成模型时,手动建模是浪费时间的。

If you already have a SQL Database it is a waste of time to model it by hand when you can quickly have a model auto generated for you based on the database.

生成模型后,您可以进入设计器并根据需要调整映射。  应该在更短的时间内给你相同的结果。

After you get your model generated you can then go into the designer and tweak mappings if you wish.  Should give you the same results in less time.

如果你想要对这些类型中的每一种进行一些正式的定义,可以找到它们的链接:

If you want some formal definitions of each of these types here are links to find them:

 


  1. 模型 - 实体框架4中的第一个
  2. 实体框架4“ Code-First”


数据库首先是什么在版本4之前执行实体框架的唯一方法。  Model-First的一个主要优点是,您可以在GUI中使用设计,直到您按照自己的方式获得它,然后创建数据库
来自它。   Code First完全不使用设计器,而是使用POCO定义模型。  正如您所看到的,您没有做其中任何一项,建议开发人员在使用EF4时坚持使用这3种方法中的一种。
Database first is what was the only way to do Entity Framework before version 4.  One of the main advantages to Model-First is that you get to play around with the design in the GUI until you get it the way you want, and then you create the database from it.  Code First doesn't use the designer at all and you define your model using POCO's.  As you can see you are not doing either of those, and it is recommend that developers stick to one of these 3 methods when using EF4.


这篇关于“数据库优先”或“模型优先”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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