我试图将我的DbSet
移至将用于数据库操作的类库项目。将简单成员资格证书功能移至类库项目
我一直在关注this教程到Code First
/SimpleMembershipProfider
项目。我已经通过class lib项目获得了充满新表等的数据库。
但我错过了webpages_表,你可以看到this图像。
这是我的DataContext类:
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
,并将它放在类项目中的app.config
中。这是app.config
文件的样子:
<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>
我不知道做什么用的过滤器文件夹(具有类InitializeSimpleMembershipAttribute
)在我webproject做。
有人能告诉我如何获得在数据库中创建的webpages_
?以及如何将websecurity等移动到类lib项目?
在此先感谢!
您是否试图控制'SimpleMembership'并将其包含在您的项目实体框架中? – Komengem 2013-05-05 17:03:38