随笔- 672
文章- 2
评论- 325
阅读-
281万
随笔分类 - EF Core
Many-to-many relationships in EF Core 2.0 – Part 3: Hiding as ICollection
摘要:In the previous post we ended up with entities that hide the join entity from the public surface. However, it was not possible to add or removed entit
阅读全文
Many-to-many relationships in EF Core 2.0 – Part 2: Hiding as IEnumerable
摘要:In the previous post we looked at how many-to-many relationships can be mapped using a join entity. In this post we’ll make the navigation properties
阅读全文
Many-to-many relationships in EF Core 2.0 – Part 1: The basics
摘要:转载这个系列的文章,主要是因为EF Core 2.0在映射数据库的多对多关系时,并不像老的EntityFramework那样有原生的方法进行支持,希望微软在以后EF Core的版本中加入原生支持多对多关系的Fluent API,这样这个系列的文章就不需要看了~ As of EF Core 2.0,
阅读全文
EF Core如何输出日志到Visual Studio的输出窗口
摘要:我们在使用EF Core的时候,很多时候需要在Visual Studio的输出窗口中知道EF Core在后台生成的SQL语句是什么,这个需求可以通过自定义EF Core的ILoggerFactory和ILogger类来实现: 首先定义一个实现了ILogger接口的类EFLogger,主要目的是将EF
阅读全文
EF Core怎么只Update实体的部分列数据
摘要:下面是EF Core中的一个Person实体: 其中我们通过Fluent API指定了Code是Key属性,用来Update和Delete数据(包括DbSet的Contains方法也是查找的实体的Key属性值): 现在我们可以通过代码先new一个Person实体,然后声明其Key属性列Code的值,
阅读全文
EF Core 2.0中怎么用DB First通过数据库来生成实体
摘要:要在EF Core使用DB First首先要下载三个Nuget包,在Nuget的Package Manager Console窗口中依次敲入下面三个命令即可: Microsoft.EntityFrameworkCore.SqlServer Install-Package Microsoft.Enti
阅读全文
EF Core中关于Microsoft.EntityFrameworkCore.DynamicLinq的使用(转载)
摘要:项目中经常用到组合条件查询,根据用户配置的查询条件进行搜索,拼接SQL容易造成SQL注入,普通的LINQ可以用表达式树来完成,但也比较麻烦。有个Microsoft.EntityFrameworkCore.DynamicLinq用起来比较方便。 NuGet: Install-Package Micro
阅读全文
在EF Core里面如何使用以前EntityFramework的DbContext.Database.SqlQuery<SomeModel>自定义查询
摘要:问: With Entity Framework Core removing dbData.Database.SqlQuery<SomeModel> I can't find a solution to build a raw SQL Query for my full-text search qu
阅读全文
Entity framework 中Where、First、Count等查询函数使用时要注意
摘要:在.Net开发中,Entity framework是微软ORM架构的最佳官方工具。我们可以使用Lambda表达式在Entity framework中DbSet<T>类上直接做查询(比如使用DbSet<T>类的Where、First、Count等查询函数)返回数据库结果实体。 不知道大家有没有注意到D
阅读全文