I have a problem similar to Entity Framework 5.0 PostgreSQL (Npgsql) factory default connection
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> <system.data> <DbProviderFactories> <add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for 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 class is "Personne":
[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 my management I am doing something like this:
using (var context = new ContextDB()) { // *** here i have an exception... var personnes = from p in context.Personnes where 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 that I have an exception:
ERROR: schema "dbo" does not exist
this is an NpgsqlException exception
[French]
ERREUR: 3F000: le schéma "dbo" n'existe pas
I don't know what's wrong with that
EDIT:
This is an exception:
(sorry, but this is in french)
PS: I do not have projects in " C: \ projects \ Npgsql2 ", and I have nothing like this in my current project, so what is it?
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" AS "C1" FROM (SELECT CAST (count(1) AS int4) AS "A1" FROM "dbo"."__MigrationHistory" AS "Extent1Group") AS "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: