简体   繁体   English

如何使edmx DbContext从IdentityDbContext继承

[英]How to make edmx DbContext inherit from IdentityDbContext

Im trying to integrate asp.net identity to my existing project i'm working with Database first, and using edmx to generate the models and context class, 我试图将asp.net身份集成到我现有的项目中,首先要使用数据库,然后使用edmx生成模型和上下文类,

Now in the Context class that is generated with edmx, i need to change the inheritance from DbContext TO IdentityDbContext but when i refresh the edmx all changes gets removed from the Context class, 现在,在用edmx生成的Context类中,我需要将继承从DbContext更改为IdentityDbContext,但是当我刷新edmx时,所有更改都将从Context类中删除,

So my question is how can i inherit from IdentityDbContext when using edmx 所以我的问题是使用edmx时如何从IdentityDbContext继承

Change these 改变这些

public ConfigurationContext(DbContextOptions<ConfigurationContext> options):base(options)    
public IdentityDbContext (DbContextOptions<IdentityDbContext> options):base(options)

to this 对此

public ConfigurationContext(DbContextOptions options):base(options) 
public IdentityDbContext (DbContextOptions options):base(options)

Example

public class QueryContext : DbContext
{
  public QueryContext(DbContextOptions options): base(options)
   {
   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM