asp.net mvc 4 - npgsql schema "dbo" does not exist -


i have problem similar entity framework 5.0 postgresql (npgsql) default connection factory

i have npgsql declared in app.config :

<connectionstrings>     <add name="mondbcontexte"           connectionstring="server=127.0.0.1;port=5432;database=ma_datab_db;user id=postgres;password=root;"       providername="npgsql" />   </connectionstrings>   <!-- le factory provider -->   <system.data>     <dbproviderfactories>       <add name="npgsql data provider"             invariant="npgsql"             support="ff"             description=".net framework data provider postgresql server"             type="npgsql.npgsqlfactory, npgsql" />     </dbproviderfactories>   </system.data> </configuration> 

my context provider class:

public class contextdb: dbcontext {     public dbset<personne> personnes { get; set; }      public contextdb()         : base("mondbcontexte")     {     } } 

my "personne" class:

[table("personnes", schema = "public")] public class personne { [key] [column("id_personne")] [display(name="identifiant")] public int id { get; set; }

    [column("nom")]     [display(name = "nom")]     [required(errormessage = "merci de saisir le nom.")]     public string nom { get; set; }      [column("prenom")]     [display(name = "prénom")]     [required(errormessage = "merci de saisir le prénom.")]     public string prenom { get; set; } ... ... } 

and in controller action this:

            using (var context = new contextdb())             {                 // *** here have exception...                 var personnes = p in context.personnes                               p.nom.startswith("m")                               orderby p.nom                               select new { p.nom, p.prenom };                  foreach (var une_personne in personnes)                 {                     console.writeline(une_personne.nom + " " + une_personne.prenom);                 } 

after have exception :

error: schema "dbo" not exist 

this npgsqlexception

[french]
erreur: 3f000: le schéma « dbo » n'existe pas

i dont undersand what's wrong in this

edit:

this exception :
(sorry in french)

ps : have no projects in "c:\projects\npgsql2" , have nothing path in current project, this??

l'exception npgsql.npgsqlexception n'a pas été gérée par le code utilisateur   hresult=-2147467259   message=erreur: 3f000: le schéma « dbo » n'existe pas   source=npgsql   errorcode=-2147467259   basemessage=le schéma « dbo » n'existe pas   code=3f000   detail=""   errorsql=select "groupby1"."a1" "c1" (select cast (count(1) int4) "a1" "dbo"."__migrationhistory" "extent1group") "groupby1"   file=src\backend\catalog\namespace.c   hint=""   line=2826   position=82   routine=get_namespace_oid   severity=erreur   where=""   stacktrace:        à npgsql.npgsqlstate.<processbackendresponses_ver_3>d__a.movenext() dans c:\projects\npgsql2\src\npgsql\npgsqlstate.cs:ligne 850        à npgsql.forwardsonlydatareader.getnextresponseobject() dans c:\projects\npgsql2\src\npgsql\npgsqldatareader.cs:ligne 1173        à npgsql.forwardsonlydatareader.getnextrowdescription() dans c:\projects\npgsql2\src\npgsql\npgsqldatareader.cs:ligne 1191        à npgsql.forwardsonlydatareader.nextresult() dans c:\projects\npgsql2\src\npgsql\npgsqldatareader.cs:ligne 1377        à npgsql.forwardsonlydatareader..ctor(ienumerable`1 dataenumeration, commandbehavior behavior, npgsqlcommand command, notificationthreadblock threadblock, boolean synchonreaderror) dans c:\projects\npgsql2\src\npgsql\npgsqldatareader.cs:ligne 1040        à npgsql.npgsqlcommand.getreader(commandbehavior cb) dans c:\projects\npgsql2\src\npgsql\npgsqlcommand.cs:ligne 611        à npgsql.npgsqlcommand.executereader(commandbehavior cb) dans c:\projects\npgsql2\src\npgsql\npgsqlcommand.cs:ligne 588        à npgsql.npgsqlcommand.executedbdatareader(commandbehavior behavior) dans c:\projects\npgsql2\src\npgsql\npgsqlcommand.cs:ligne 538        à system.data.common.dbcommand.executereader(commandbehavior behavior)        à system.data.entityclient.entitycommanddefinition.executestorecommands(entitycommand entitycommand, commandbehavior behavior)   innerexception:  

it seems ef uses dbo default schema database. need change "public" default schema postgresql.

you use importing namespace:

using system.componentmodel.dataannotations; 

and annotate classes use different schema:

[table("mytable", schema = "public")] class test {...} 

for more information, check out post ef , npgsql: http://fxjr.blogspot.com/2013/06/npgsql-code-first-entity-framework-431.html

i hope helps.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -