2013-03-11 18 views
7

Burada Rol Yöneticisi özelliği etkin değil benim yapılandırma sınıfı ve web yapılandırma var i paket yöneticisi konsolunda benim veritabanını güncellemek o hata var. bana lütfen yardımRol Yöneticisi özelliği etkin değil. MVC 4

MY YAPILANDIRMA SINIF

namespace TechFactorsLMSV2.Migrations 
{ 
using System; 
using System.Data.Entity; 
using System.Data.Entity.Migrations; 
using System.Linq; 
using System.Web.Security; 
using TechFactorsLMSV2.Models; 
using WebMatrix.WebData; 

internal sealed class Configuration : DbMigrationsConfiguration<TechFactorsLMSV2.Models.LMSDBContext> 
{ 
    public Configuration() 
    { 
     AutomaticMigrationsEnabled = false; 
    } 

    protected override void Seed(TechFactorsLMSV2.Models.LMSDBContext context) 
    { 
     context.Schools.AddOrUpdate(d => d.SchoolName, 
       new School() { SchoolName = "School 1" }, 
       new School() { SchoolName = "School 2" }, 
       new School() { SchoolName = "School 3" } 
       ); 

     SeedMembership(); 
    } 

    private void SeedMembership() 
    { 
     WebSecurity.InitializeDatabaseConnection("DefaultConnection", 
      "UserProfile", "UserId", "UserName", autoCreateTables: true); 
     var roles = (SimpleRoleProvider)Roles.Provider; 
     var membership = (SimpleMembershipProvider)Membership.Provider; 

     if (!roles.RoleExists("Admin")) 
     { 
      roles.CreateRole("Admin"); 
     } 
     if (membership.GetUser("kadadmin", false) == null) 
     { 
      membership.CreateUserAndAccount("kadadmin", "password"); 
     } 
     if (!roles.GetRolesForUser("kadadmin").Contains("Admin")) 
     { 
      roles.AddUsersToRoles(new[] { "sallen" }, new[] { "admin" }); 
     } 
    } 
} 
} 

MY WEB CONFIG Sen system.web bölümü altında web.config için bu eklemeniz gerekir

<?xml version="1.0"?> 

<configuration> 
<configSections> 
<sectionGroup name="system.web.webPages.razor"  type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
    <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /> 
    <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /> 
</sectionGroup> 
</configSections> 
<connectionStrings> 
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-TechFactorsLMSV2;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\TechFactorsLMSV2.mdf" providerName="System.Data.SqlClient" /> 
    </connectionStrings> 

<system.web.webPages.razor> 
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
<pages pageBaseType="System.Web.Mvc.WebViewPage"> 
    <namespaces> 
    <add namespace="System.Web.Mvc" /> 
    <add namespace="System.Web.Mvc.Ajax" /> 
    <add namespace="System.Web.Mvc.Html" /> 
    <add namespace="System.Web.Optimization"/> 
    <add namespace="System.Web.Routing" /> 
    </namespaces> 
</pages> 



</system.web.webPages.razor> 

<appSettings> 
<add key="webpages:Enabled" value="false" /> 
</appSettings> 



<system.web> 
<httpHandlers> 
    <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/> 
</httpHandlers> 

<!-- 
    Enabling request validation in view pages would cause validation to occur 
    after the input has already been processed by the controller. By default 
    MVC performs request validation before a controller processes the input. 
    To change this behavior apply the ValidateInputAttribute to a 
    controller or action. 
--> 
<pages 
    validateRequest="false" 
    pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" 
    pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" 
    userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
    <controls> 
    <add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" /> 
    </controls> 
</pages> 



<roleManager enabled="true" defaultProvider="simple"> 
    <providers> 
    <clear/> 
    <add name="simple" type="WebMatrix.WebData.SimpleRoleProvider, 
         WebMatrix.WebData"/> 
    </providers> 
</roleManager> 
<membership defaultProvider="simple"> 
    <providers> 
    <clear/> 
    <add name="simple" type="WebMatrix.WebData.SimpleMembershipProvider, 
         WebMatrix.WebData"/> 
    </providers> 
</membership> 

</system.web> 

<system.webServer> 
<validation validateIntegratedModeConfiguration="false" /> 

<handlers> 
    <remove name="BlockViewHandler"/> 
    <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" /> 
</handlers> 

cevap

10

<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> 
+0

Şimdi diyor 'WebMatrix.WebData' dosyası veya derlemesi yüklenemedi veya bağımlılıklarından biri. Sistem belirtilen dosyayı bulamıyor. – dnxit

+2

WebMatrix.WebData derlemesi için başvuru ekleyin –

+0

CopyLocal öğesinin true olarak ayarlanmış olduğuna bakın. – StefanG