什么是实体框架“数据库优先”和“守则第一现有的数据库'之间的区别 [英] What is the difference between 'Database First' and 'Code First to Existing Database' in Entity Framework

查看:132
本文介绍了什么是实体框架“数据库优先”和“守则第一现有的数据库'之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚看了有关新守则第一现有的数据库功能在EF6.1 MSDN的视频

I have just watched the MSDN video about the new 'Code First to Existing Database' functionality in EF6.1

http://channel9.msdn.com/Blogs/EF/Code-First-对现有的数据库内,EF6-1-后续版本

不过,作为新EF,这似乎可以从数据库生成POCO模型类这也正是我想'数据库优先做(我理解'DB第一'是'代码优先​​的对面)

However, being new to EF, this appears to be generating POCO Model classes from a DB, which is exactly what I thought 'Database First' does (and I understood 'DB First' to be the opposite of 'Code First')

有什么区别?他们都是数据库第一'!

What's the difference? They are both 'database first'!

推荐答案

代码首先是有点儿名不副实......它应该真正被称为是基于代码的模型与基于XML的模型。

Code First is sort of a misnomer... What it should really be called is "Code Based Model" vs "XML Based Model".

代码首先创建的基础上对代码类和/或流利的映射属性的内存模式。

Code first creates an in-memory model based on attributes on classes and/or fluent mappings in code.

数据库和模型首先创建一个基于.edmx文件,然后用来生成类的内存模型。

Database and Model first create an in-memory model based on a .EDMX file, which is then used to generate classes.

IE浏览器。代码首先使用代码作为它的模型。数据库和模型首先使用EDMX文件,因为它的模式。代码首先对现有的数据库刚刚生成代码的第一类(属性和/或流利的映射),而数据库首先生成一个EDMX文件,然后通过T4模板生成的类。

ie. Code first uses the code as its model. Database and Model first use the EDMX file as it's model. Code First to existing database just generates code first classes (attributes and/or fluent mapping), while database first generates an EDMX file which then generates classes via T4 templates.

这篇关于什么是实体框架“数据库优先”和“守则第一现有的数据库'之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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