Entity Framework Core allows you to drop down to raw SQL queries when working with a relational database. This can be useful if the query you want to perform can't be expressed using LINQ, or if using a LINQ query is resulting in inefficient SQL bein…
Raw SQL Queries Entity Framework allows you to query using LINQ with your entity classes. However, there may be times that you want to run queries using raw SQL directly against the database. This includes calling stored procedures, which can be help…
原文 Executing Raw SQL Queries using Entity Framework While working with Entity Framework developers mostly use LINQ to Entities to query database. However, at times you may need to execute raw queries against the database. A common scenario is when yo…
前言 如果大家刚使用EntityFramework Core作为ORM框架的话,想必都会遇到数据库迁移的一些问题. 起初我是在ASP.NET Core的Web项目中进行的,但后来发现放在此处并不是很合理,一些关于数据库的迁移,比如新增表,字段,修改字段类型等等,不应该和最上层的Web项目所关联,数据的迁移文件放到这里也感觉有点多余,有点乱乱的感觉,所以才想着单独出来由专门的项目进行管理会比较好,也比较清晰! 注意目标框架选择的是.NET Core 2.0而不是.NET Standard 2.0.…
通过ef core 源码分析 Microsoft.EntityFrameworkCore.Storage.RelationalCommandExtensions类中有相应的方法 为此得到相应的结果: 为此在我们的数据上下文中拓展方法: public async Task<DbDataReader> ExecuteReaderAsync(RawSqlString sql, params object[] parameters) { using (await Database.GetService…
我们使用EF Core的实体类向SQL Server数据库表中插入数据后,如果数据库表中有自增列或默认值列,那么EF Core的实体对象也会返回插入到数据库表中的默认值. 下面我们通过例子来展示,EF Core是怎么获取数据库的默认值的.首先我们建立一个.NET Core控制台项目,然后引入EF Core所需的NuGet包. 获取自增列值 我们在SQL Server数据库中建立一个表Person,该表有一个自增列ID为主键: CREATE TABLE [dbo].[Person]( ,) NOT…
官方文档英文地址:https://github.com/aspnet/EntityFramework/wiki/Roadmap 历经延期和更名,新版本的实体框架终于要和大家见面了,虽然还有点害羞.请大家多体谅! 下面正式进入主题: Entity Framework Core (EF Core) 下面是EF Core 的计划和技术线路,注意,这些计划是可能发现变化的,因为很多事是很难预测的.即便如此,我们还是尽可能保持计划的公开和透明,以解大家对EF Core期望,以及做出相应的安排. Sched…
本文转自:https://stackoverflow.com/questions/43935345/how-to-get-return-values-and-output-values-from-a-stored-procedure-with-ef-core 问题未解决 ALTER PROCEDURE [dbo].[SearchMovies] --@Year int = null, @CategoryIds varchar(50) = null, @Keywords nvarchar(4000)…
本文转自:http://www.cnblogs.com/VolcanoCloud/p/5572408.html 官方文档英文地址:https://github.com/aspnet/EntityFramework/wiki/Roadmap 历经延期和更名,新版本的实体框架终于要和大家见面了,虽然还有点害羞.请大家多体谅! 下面正式进入主题: Entity Framework Core (EF Core) 下面是EF Core 的计划和技术线路,注意,这些计划是可能发现变化的,因为很多事是很难预测…
Entity Framework Core performance tuning – a worked example Last Updated: February 25, 2019 | Created: September 22, 2017 This is the first in a series of articles on performance tuning EF Core. In this article I take an example book selling site tha…