避免 IEnumerable 以及 IQueryable 陷阱: IEnumerable示用Linq会先去数据库查询所有记录,然后再条件查询. IQueryable接口派生自IEnumerable,但表示数据库应该处理的查询.也就是说IQueryable会把查询的条件写入sql语句,而并不是先取出所有数据后再筛选. IQueryable接口的使用改变了对 LINQ 查询的评估方式,并确保筛选是由数据库服务器而不是由 MVC 应用程序执行的.只检索符合筛选条件的数据库中的数据,并且不会创建任何立即…
Reading related data¶ 9 of 9 people found this helpful The Contoso University sample web application demonstrates how to create ASP.NET Core 1.0 MVC web applications using Entity Framework Core 1.0 and Visual Studio 2015. For information about the tu…
Sorting, filtering, paging, and grouping 7 of 8 people found this helpful By Tom Dykstra The Contoso University sample web application demonstrates how to create ASP.NET Core 1.0 MVC web applications using Entity Framework Core 1.0 and Visual Studio…
原文地址:https://docs.asp.net/en/latest/data/ef-mvc/intro.html The Contoso University sample web application demonstrates how to create ASP.NET Core 1.0 MVC web applications using Entity Framework Core 1.0 and Visual Studio 2015. Contoso University网络应用的案…
不定时更新翻译系列,此系列更新毫无时间规律,文笔菜翻译菜求各位看官老爷们轻喷,如觉得我翻译有问题请挪步原博客地址 本博文翻译自: http://gunnarpeipman.com/2017/08/ef-core-global-query-filters/ Entity Framework Core 2.0 全局查询过滤器 Entity Framework Core 2.0引入了全局查询过滤器,可以在创建模型时应用到实体 .它使得构建多租户应用程序和支持对实体 的软删除变得更加容易.这篇博客文章提…
使用ASP.NET Core MVC 和 Entity Framework Core 开发一个CRUD(增删改查)的应用程序 不定时更新翻译系列,此系列更新毫无时间规律,文笔菜翻译菜求各位看官老爷们轻喷,如觉得我翻译有问题请挪步原博客地址 本博文翻译自: http://l-knowtech.com/2017/08/28/first-crud-application-asp-net-core-mvc-using-entity-framework-core/ 本文打算使用ASP.NET Core M…
Entity Framework Core 2.0 中使用LIKE 操作符 不定时更新翻译系列,此系列更新毫无时间规律,文笔菜翻译菜求各位看官老爷们轻喷,如觉得我翻译有问题请挪步原博客地址 本博文翻译自: http://gunnarpeipman.com/2017/08/ef-core-like-operator/ Entity Framework Core 2.0 早前发布,它带来了一些新的.很酷的特性.其中一个是SQL like操作符,我们现在可以直接在代码中使用它.下面是一个简单的web应…
一.前言 我们在使用EF进行开发的时候,肯定会遇到将迁移更新到生产数据库这个问题,前面写了一篇文章介绍了Entity Framework Core 2.0的入门使用,这里面介绍了使用命令生成迁移所需的SQL,然后更新到生产数据库的方法.这里还有另一种方法,就是利用EF Core自身所提供的方法来进行迁移. 二.API说明 这些方法都是DatabaseFacade的扩展方法,我们常使用的DbContext.Database就是DatabaseFacade类型. GetMigrations 获取所有…
上一篇我们介绍了Entity Framework Core系列之DbContext,对DbContext有了概念上的了解,这篇将介绍DbContext添加数据 通过DbContext添加实体的主要方法: Add<TEntity>(TEntity entity) Add(object entity) AddRange(IEnumerable<object> entities) AddRange(params object[] entities) 这些方法是EF Core 中DbCon…
1.add-migration : 无法将“add-migration”项识别为 cmdlet.函数.脚本文件或可运行程序的名称.请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次. 使用Entity Framework Core命令 add-migration manage 出现以下错误 PM> add-migration manage add-migration : 无法将“add-migration”项识别为 cmdlet.函数.脚本文件或可运行程序的名称.请检查名称的拼写,如果…