“数据库优先”或“模型优先”? [英] "Database First" or "Model First"?
问题描述
我了解使用实体框架有三种可能的方式 -
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:
来自它。 Code First完全不使用设计器,而是使用POCO定义模型。 正如您所看到的,您没有做其中任何一项,建议开发人员在使用EF4时坚持使用这3种方法中的一种。
这篇关于“数据库优先”或“模型优先”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!