如何将MVC5 ASP.NET生成的身份代码实现到现有数据库中 [英] How to implement MVC5 ASP.NET generated identity code into an existing database

查看:89
本文介绍了如何将MVC5 ASP.NET生成的身份代码实现到现有数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所说,我使用visual c#和身份验证创建了一个新的MVC项目。然后我实现了所需的模型(并使用代码第一实体框架创建了数据库)。我现在要做的是向该数据库添加由visual studio创建的身份验证的智能,并添加它来映射我的实体。

例如,我有一个名为Clients的表。我希望每个客户端都拥有自己的登录和权限。我该怎么做?

由于

解决方案
实体框架是基于DML的东西(数据操纵) ,所以将它用于CRUD操作不会是一个坏主意。但是在它上面创建一个登录系统,不是一个好主意。你必须创建很多模块和其他东西。所以,不要!



而不是这个,你可以使用 ASP.NET身份 [ ^ ]。身份具有很多好的功能,并且允许您控制所有内容(是,所有内容)。您可以使用API​​创建自己的服务并在应用程序中使用它们,更改Identity System的工作方式,向其中添加更多包等等。



因此,您应该使用 ASP而不是使用Entity框架进行用户登录和权限(组或角色,对?) .NET标识


As the title says, I created a new MVC project with visual c# and authentication. Then I've implemented the desired models (and created the database with code first entity framework). What I want to do now is add to that database the intelligence of the authentication that was created by visual studio and addapt it to map my entities.
For instance, I've got a table called Clients. I want that each client have it's own login and permissions. How can I do that?
Thanks

解决方案

Entity framework is based on DML stuff (data manipulation), so using it for CRUD operations won't be a bad idea. But creating a login system on the top of it, would not be a good idea. You would have to create a lot of modules and other stuff. So, don't!

Instead of this, you can use ASP.NET Identity[^]. Identity has a lot of good features, and allows you to take controls of everything (yes, everything) that goes on under the hood. You can use the API to create your own services and use them in your application, change how the Identity system works, add more packages to it and so on.

So, instead of using Entity framework for user logins and permissions (groups or roles, right?) you should use ASP.NET Identity.


这篇关于如何将MVC5 ASP.NET生成的身份代码实现到现有数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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