将简单的成员资格提供者功能移至类库项目 [英] Move simple membership profider functionality to class library project
问题描述
我正在尝试将DbSet
移到将用于数据库操作的类库项目中.
I'm trying to move my DbSet
's to a class library project that is going to be used for database operations.
I've been following this tutorial to a Code First
/ SimpleMembershipProfider
project. I've already got the database filled with new tables etc, via the class lib project.
但是我缺少您可以在此图片上看到的webpages_表.
But i am missing the webpages_ tables you can see on this image.
这是我的数据上下文类:
This is my datacontext class:
public class DataContext : DbContext
{
public DataContext() : base("DefaultConnection")
{
}
public DbSet<Orders> Orders { get; set; }
public DbSet<Appointment> Appointment { get; set; }
public DbSet<UserProfile> UserProfile { get; set; }
}
我为每个DbSet
创建了一个CS文件.我从web.config
复制了connectionString
,并将其放在类lib项目的app.config
中. app.config
文件的外观如下:
And for every DbSet
i created a cs file. I copied the connectionString
from the web.config
and placed it in the app.config
in the class lib project. This is how the app.config
file looks like:
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.;Initial Catalog=aspnet-CodeFirst-test;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<roleManager enabled="true" defaultProvider="SimpleRoleProvider">
<providers>
<clear />
<add name="SimpleRoleProvider" type="WebMatrix.WebData.SimpleRoleProvider, WebMatrix.WebData" />
</providers>
</roleManager>
<membership defaultProvider="SimpleMembershipProvider">
<providers>
<clear />
<add name="SimpleMembershipProvider" type="WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData" />
</providers>
</membership>
</system.web>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
</configuration>
我不确定该如何处理我的Web项目中的Filters文件夹(类为InitializeSimpleMembershipAttribute
).
I'm not sure what to do with the Filters folder (which has the class InitializeSimpleMembershipAttribute
) in my webproject.
有人可以告诉我如何在数据库中创建webpages_
吗?以及如何将网络安全等移至类库项目?
Can someone tell me how to get the webpages_
created in the database? And how to move websecurity etc to the class lib project?
提前谢谢!
推荐答案
如果您试图控制Asp.net简单成员资格表和/或将Asp.net简单成员资格表作为实体框架的一部分进行建模,则您的项目实体框架,您需要采取许多步骤.我会逐步解释它们,但是会花费太长时间,因此我只会为您提供参考.
If you trying to take control of Asp.net Simple Membership Table and or Including Asp.net Simple Membership Tables as Part of Your Entity Framework Model your Project Entity framework, there is a number of steps you need to take. I would explain them step by step but it would take too long so i will just provide you with references.
使用ASP.NET MVC 4构建应用程序.您可以在复数版本上使用试用版
如果您有任何具体问题,我很乐意回答.
If you have any specific questions, i would be happy to answer them.
这篇关于将简单的成员资格提供者功能移至类库项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!