I try to make a simple web application. There will be very few users(one or two). No need to make complicated membership stuff. I need just basic login process. I use Visual Studio 2013
我尝试做一个简单的web应用程序。只有很少的用户(一两个)。不需要制作复杂的会员卡。我只需要基本的登录过程。我使用Visual Studio 2013
I made some research on the internet and found something about ASP.NET Identity. However i could not found anything about how to install Identity tables to my own mssql database.
我在网上做了一些调查,发现了一些关于ASP的东西。净的身份。但是,我找不到关于如何将标识表安装到我自己的mssql数据库的任何信息。
I used ASP.NET membership before and it was easy to install tables by using aspnet_regsql.exe and adding some codes to web.config
我使用ASP。使用aspnet_regsql很容易安装表。在web.config中添加一些代码
But now i am really confused with Identity stuff. It uses a default database to store users. But in my server there will be my sql database that stores both my datas and user datas.
但现在我真的对身份问题感到困惑。它使用一个默认的数据库来存储用户。但是在我的服务器中,将会有我的sql数据库存储我的数据和用户数据。
How can i combine these two databases into one? How can I install Identity tables to my own database and configure my Project to use it?
如何将这两个数据库合并为一个?如何将标识表安装到自己的数据库中并配置我的项目以使用它?
2 个解决方案
#1
1
It sounds like you just want the Identity tables to use the same database as the rest of your application. If you're using a new Identity project in Visual Studio 2013, it should be using Entity Framework, which simplifies things significantly.
听起来您只是希望标识表与应用程序的其他部分使用相同的数据库。如果您在Visual Studio 2013中使用了一个新的身份项目,那么它应该使用Entity Framework,这大大简化了事情。
You should be able to make this happen by making sure the Identity code uses the same connection string as your own database context. If you change the "DefaultConnection" string in Web.config to point to your own database, Entity Framework will take care of the rest.
您应该能够通过确保标识代码使用与您自己的数据库上下文相同的连接字符串来实现这一点。如果您更改Web中的“DefaultConnection”字符串。配置指向您自己的数据库,实体框架将负责其余部分。
If you got rid of the "DefaultConnection" connection, you can change the string used in IdentityModels.cs (in the Models folder of your project) to be your custom string. Look for:
如果删除了“DefaultConnection”连接,您可以更改标识模型中使用的字符串。cs(在项目的Models文件夹中)是您的自定义字符串。寻找:
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
and change the string in base().
并在base()中更改字符串。
Again, the magic of Entity Framework is that it'll automatically create the tables and relationships it needs without requiring you to build them yourself. EF6 is also really good about handling versioning when there are multiple contexts, so you shouldn't get any "model changed" errors unless you got rid of the __MigrationHistory table.
同样,实体框架的神奇之处在于,它将自动创建所需的表和关系,而不需要您自己构建它们。EF6也非常适合在有多个上下文时处理版本控制,所以您不应该得到任何“模型更改”错误,除非您删除了__MigrationHistory表。
#2
0
You should use Entity Framework you can take different approach like code first ,Model First DB First.
您应该使用实体框架,您可以采用不同的方法,如代码优先、模型优先、数据库优先。
It will make much easier process for you.
这将使你的过程更容易。
Here is some good links.
这里有一些很好的链接。
如何安装
http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application
#1
1
It sounds like you just want the Identity tables to use the same database as the rest of your application. If you're using a new Identity project in Visual Studio 2013, it should be using Entity Framework, which simplifies things significantly.
听起来您只是希望标识表与应用程序的其他部分使用相同的数据库。如果您在Visual Studio 2013中使用了一个新的身份项目,那么它应该使用Entity Framework,这大大简化了事情。
You should be able to make this happen by making sure the Identity code uses the same connection string as your own database context. If you change the "DefaultConnection" string in Web.config to point to your own database, Entity Framework will take care of the rest.
您应该能够通过确保标识代码使用与您自己的数据库上下文相同的连接字符串来实现这一点。如果您更改Web中的“DefaultConnection”字符串。配置指向您自己的数据库,实体框架将负责其余部分。
If you got rid of the "DefaultConnection" connection, you can change the string used in IdentityModels.cs (in the Models folder of your project) to be your custom string. Look for:
如果删除了“DefaultConnection”连接,您可以更改标识模型中使用的字符串。cs(在项目的Models文件夹中)是您的自定义字符串。寻找:
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
and change the string in base().
并在base()中更改字符串。
Again, the magic of Entity Framework is that it'll automatically create the tables and relationships it needs without requiring you to build them yourself. EF6 is also really good about handling versioning when there are multiple contexts, so you shouldn't get any "model changed" errors unless you got rid of the __MigrationHistory table.
同样,实体框架的神奇之处在于,它将自动创建所需的表和关系,而不需要您自己构建它们。EF6也非常适合在有多个上下文时处理版本控制,所以您不应该得到任何“模型更改”错误,除非您删除了__MigrationHistory表。
#2
0
You should use Entity Framework you can take different approach like code first ,Model First DB First.
您应该使用实体框架,您可以采用不同的方法,如代码优先、模型优先、数据库优先。
It will make much easier process for you.
这将使你的过程更容易。
Here is some good links.
这里有一些很好的链接。
如何安装
http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application