实体框架核心中的HasDefaultSchema在哪里? [英] Where is HasDefaultSchema in Entity Framework Core?
问题描述
我要将EF移植到EF Core。新的API中似乎没有 HasDefaultSchema 方法。此代码EF Core等效于什么?
I'm porting my EF to EF Core. There doesn't appear to be a HasDefaultSchema method in the new API. What is the equivalent of this code EF Core?
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasDefaultSchema("Notifications");
}
推荐答案
It's exactly the same as the sample code.
与EF6的唯一区别在于,由于大多数EF Core流利(且不仅限于)方法,它被实现为EF6的扩展方法(而不是实例方法)。 RelationalModelBuilderExtensions
类。
The only difference with EF6 is that as most of the EF Core fluent (and not only) method it's implemented as extension method (rather than instance method) of the ModelBuilder
class inside the RelationalModelBuilderExtensions
class.
,请确保您引用 Microsoft.EntityFrameworkCore.Relational nuget ,并且使用Microsoft.EntityFrameworkCore;
In order to use it, make sure you reference the Microsoft.EntityFrameworkCore.Relational nuget, and have using Microsoft.EntityFrameworkCore;
这篇关于实体框架核心中的HasDefaultSchema在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!