实体框架核心中的HasDefaultSchema在哪里? [英] Where is HasDefaultSchema in Entity Framework Core?

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

问题描述

我要将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的扩展方法(而不是实例方法)。 ModelBuilder 类-2.1 rel = nofollow noreferrer> 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屋!

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