合并MyDbContext到Asp.net IdentityDbContext [英] Merge MyDbContext to Asp.net IdentityDbContext

查看:591
本文介绍了合并MyDbContext到Asp.net IdentityDbContext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了很多的例子在线,但没有,我可以从顶部使用上下有关合并我自己的DbContext与Asp.net IdentityDbContext。

I saw a lot of examples online but none that I could use from top to bottom about merging my own DbContext with Asp.net IdentityDbContext.

有人请引导我吗?我在步骤0,我要的是有由ASP.net IdentityDbContext我自己的数据库中生成的表格,让我可以在我自己的数据库中保存的用户数据。我怎样才能做到这一点?

Can someone please walk me through it? I am at step 0, and what I want is to have the tables generated by ASP.net IdentityDbContext inside my own database, so that I can retain user data in my own database. How can I achieve that?

感谢名单提前:)

推荐答案

如果我给你改正,你要使用现有的数据库,表用户和现有用户使用asp.net身份框架。

If I got you correct, you are trying to use your existing database, tables and existing users with asp.net identity framework.

第一件事,据我了解,你无法合并使用'IdentityDbContext你的数据库环境(MyDbContext),因为asp.net身份框架表的情况下,必须从 IdentityDbContext&LT继承; YourUserTable&GT ; 。但是,你的其他表可以从的DbContext 继承。

First thing, according to my understanding, you can't merge your db context (MyDbContext) with 'IdentityDbContext', because context of asp.net identity framework tables has to be inherited from IdentityDbContext<YourUserTable>. But your other tables may inherited from DbContext.

因此​​,你必须,如果你想使用的身份框架构建方法的支持,这是的UserManager等使用两个单独的数据库环境。

Therefore you have to use two separate db contexts if you want to use identity framework build in method support, which is UserManager etc.

您可以使用带有标识的框架现有的数据库,你只需要绑定正确使用模型绑定身份框架EF code第一种方法你的数据库表。

You can use your existing database with identity framework, you just need to correctly bind your database tables with identity framework EF code first approach using model binding.

有一个YouTube的视频教程,可以帮助您得到一些想法,以达到你的任务。其实这个视频演示了使用Identity 2.0和现有的数据库。

There is a YouTube video tutorial which may help you to get some idea in order to achieve your task. Actually this video illustrates to use Identity 2.0 with existing database.

第1部分: https://www.youtube.com/watch?v=elfqejow5hM

2部分: https://www.youtube.com/watch?v=JbSqi3Amatw

希望这有助于。

这篇关于合并MyDbContext到Asp.net IdentityDbContext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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