Salut à toutes et à tous,

Voulant me mettre au mvc, j'ai créé une nouvelle appli mvc 4 sous VS.
Comme ma base de donnée est PostgreSQL, j'ai cherché, cherché, cherché et j'ai trouvé pgprovider (ASP.NET 4.0 Membership and Role Providers for PostgreSQL). Je l'ai installé via le Nuget et j'ai modifié mes fichiers comme ceci :
web.config :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
 
<?xml version="1.0" encoding="utf-8"?><!--
  Pour plus d’informations sur la configuration de votre application ASP.NET, consultez la page
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <!--<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />-->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <!--<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-Mvc4TopocomIntranet-20140902084034;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-Mvc4TopocomIntranet-20140902084034.mdf" providerName="System.Data.SqlClient" />-->
    <add name="DefaultConnection" connectionString="Server=192.168.10.5;Port=5432;Database=Datas;User Id=mvc4Appli;Password=Pass;" providerName="Npgsql" />
    <add name="personnelPgProvider" connectionString="Server=127.0.0.1;Port=5432;Database=Personnel;User Id=mvc4Appli;Password=Pass;" providerName="Npgsql" />
  </connectionStrings>
 
 
 
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="enableSimpleMembership" value="false" />
    <add key="autoFormsAuthentication" value="false" />
  </appSettings>
  <system.web>
    <membership defaultProvider="pgMembershipProvider">
      <providers>
        <clear />
        <add name="pgMembershipProvider" type="pgProvider.pgMembershipProvider, pgProvider" applicationName="TestAppli" connectionStringName="personnelPgProvider" />
      </providers>
    </membership>
    <roleManager defaultProvider="pgRoleProvider">
      <providers>
        <clear />
        <add name="pgRoleProvider" type="pgProvider.pgRoleProvider, pgProvider" applicationName="TestAppli" connectionStringName="personnelPgProvider" />
      </providers>
    </roleManager>    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" />
    </authentication>
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <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" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
  <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers></system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
</configuration>
AccountController.cs
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System;
using System.Collections.Generic;
using System.Linq;
using System.Transactions;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using DotNetOpenAuth.AspNet;
using Microsoft.Web.WebPages.OAuth;
using WebMatrix.WebData;
using Mvc4TopocomIntranet.Filters;
using Mvc4TopocomIntranet.Models;
 
 
namespace Mvc4TopocomIntranet.Controllers
{
    public class AccountController : Controller
    {
        public ActionResult Login(string returnUrl)
        {
            ViewBag.ReturnUrl = returnUrl;
            return View();
        }
 
 
        [HttpPost]
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
 
 
                if (Membership.ValidateUser(model.UserName, model.Password))
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                    if (Url.IsLocalUrl(returnUrl))
                    {
                        return Redirect(returnUrl);
                    }
                    else
                    {
                        return RedirectToAction("Index", "Accueil");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Le nom d'utilisateur ou mot de passe fourni est incorrect.");
                }
            }
            return View(model);
        }
 
 
        public ActionResult LogOff()
        {
            FormsAuthentication.SignOut();
 
 
            return RedirectToAction("Login", "Account");
        }
 
 
        public ActionResult Register()
        {
            return View();
        }
 
 
        [HttpPost]
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                MembershipCreateStatus status;
 
 
                MembershipUser membershipUser = (Membership.Provider).CreateUser(
                    model.UserName, model.Password, null, null, null, true, null, out status);
 
 
                if (membershipUser != null)
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, false);
                    return RedirectToAction("Index", "Accueil");
                }
                else
                {
                    ModelState.AddModelError("", "Erreur d'inscription");
                }
            }
            return View(model);
        }
    }
}
Lorsque j'essaye une connexion, j'obtiens l'erreur "ERREUR: 42704: le type « user_record » n'existe pas" dans VS à la ligne if (Membership.ValidateUser(model.UserName, model.Password)) de public ActionResult Login(LoginModel model, string returnUrl).

Dans l'explorateur internet, cela se traduit par :
Erreur du serveur dans l'application '/'.


Erreur de configuration

[FONT=Arial, Helvetica, Geneva, SunSans-Regular, sans-serif]Description : Une erreur s'est produite lors du traitement d'un fichier de configuration requis pour répondre à cette demande. Veuillez consulter ci-dessous les détails relatifs à l'erreur en question, puis modifier votre fichier de configuration de manière appropriée.

Message d'erreur de l'analyseur: ERREUR: 42704: le type « user_record » n'existe pas

Erreur source:

Ligne 30 : <providers>
Ligne 31 : <clear />
Ligne 32 : <add name="pgMembershipProvider" type="pgProvider.pgMembershipProvider, pgProvider" applicationName="TestAppli" connectionStringName="personnelPgProvider" />
Ligne 33 : </providers>
Ligne 34 : </membership>

Fichier source : D:\Users\Jean-Marc\Google Drive\Projets Visual Studio 2012\Mvc4TopocomIntranet\Mvc4TopocomIntranet\web.config Ligne : 32


Informations sur la version : Version Microsoft .NET Framework :4.0.30319; Version ASP.NET :4.0.30319.18446
[/FONT]
Je pense que le problème n'est pas à la connexion, parce que si j'essaye la commande d'inscription d'un nouvel utilisateur, l'utilisateur est bien créé, pourtant j'ai la même erreur à la ligne MembershipUser membershipUser = (Membership.Provider).CreateUser(model.UserName, model.Password, null, null, null, true, null, out status); de public ActionResult Register(RegisterModel model).


Je ne comprend vraiment pas ce qui crée ce problème, donc je ne vois pas comment le résoudre.

Merci de vos z'avis z'avisés,
JM