Where is HasDefaultSchema in Entity Framework Core?

£可爱£侵袭症+ 提交于 2019-12-10 16:25:51

问题


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");
  }

回答1:


It's exactly the same as the sample code.

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.

In order to use it, make sure you reference the Microsoft.EntityFrameworkCore.Relational nuget, and have using Microsoft.EntityFrameworkCore;



来源:https://stackoverflow.com/questions/51310255/where-is-hasdefaultschema-in-entity-framework-core

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!