mvc中的实体框架 [英] Entity Framework in mvc

查看:133
本文介绍了mvc中的实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过实体框架从mvc存储​​和检索数据到sql server。

和有关实体框架的详细信息。

How to store and retrieve data to sql server from mvc through entity framework.
and detail about entity framework.

推荐答案

In mvc你可以使用两种方法通过实体框架进行数据通信

1.代码第一种方法:首先在代码中你需要从临时级别创建类,在代码第一种方法中我们避免使用可视化设计器实体框架。换句话说,.EDMX文件被排除在解决方案之外。所以你现在可以完全控制上下文类和实体类。



2.数据库第一种方法:如果你已经创建了数据库并且你想要用户在您的应用程序中,您可以通过添加.Edmx文件来使用数据库优先方法。

注意:如果您对OOP和C#编码知之甚少,则应使用数据库第一方法。



以下链接是代码优先和数据库冷杉方法的示例,您可以在Google上搜索您的要求。



代码链接首先



http ://www.asp.net/mvc/tutorials/mvc-4 [ ^ ]





http://code.msdn.microsoft.com/ASPNET-MVC-Application-b01a9fe8 [ ^ ]





如何为MVC使用实体框架代码优先3 [ ^ ]



数据库链接首先



http://www.asp.net/mvc/tutorials/mvc- 5 /数据库优先开发/设置数据库 [ ^ ]





http://msdn.microsoft.com/en-in/data/gg685489.aspx [ ^ ]





使用ASP.NET MVC脚手架和实体框架进行数据库优先开发 [ ^ ]
In mvc you can use two methods for data communication by entity framwork
1. Code first method : In code first you need to create class from the scratch level, In code first approach we avoid working with visual designer of entity framework. In other words the .EDMX file is excluded from the solution. So you now have complete control over the context class as well as the entity classes.

2. Database First method : If you have database already created and you want to user the same in your application then you can use database first method by adding .Edmx file.
Note : If you have less knowledge of OOP and C# coding the you should use database firs method.

Following links are the examples of code first and database firs method and you can search on the google as your requirement.

Links for Code first

http://www.asp.net/mvc/tutorials/mvc-4[^]


http://code.msdn.microsoft.com/ASPNET-MVC-Application-b01a9fe8[^]


How to use Entity Framework Code First for MVC 3[^]

Links for Database first

http://www.asp.net/mvc/tutorials/mvc-5/database-first-development/setting-up-database[^]


http://msdn.microsoft.com/en-in/data/gg685489.aspx[^]


Database First Development with ASP.NET MVC Scaffolding and Entity Framework[^]


这篇关于mvc中的实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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