IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Entity Framework Discussion :

Problème démarrage avec Entity Framework


Sujet :

Entity Framework

  1. #1
    Candidat au Club
    Femme Profil pro
    Développeur .net
    Inscrit en
    Mai 2006
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 46
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur .net

    Informations forums :
    Inscription : Mai 2006
    Messages : 4
    Points : 4
    Points
    4
    Par défaut Problème démarrage avec Entity Framework
    Bonjour,
    J'essaie de me mettre à EntityFramework depuis quelques temps en utlisant quelques tutos comme par exemple :
    http://blogs.msdn.com/b/adonet/archi...lkthrough.aspx

    Je rajoute bien les références à EntityFramework et System.Data.Entity mais à chaque fois que je fais un run de l'application j'ai une exception sur l'appel d'une méthode de DBContext :

    Method not found: '!1 System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(!0, System.Func`2<!0,!1>)'
    J'ai essaie plusieurs tutos et j'ai toujours la même erreur, quelqu'un aurait une idée, une piste ?

    Merci d'avance pour vos réponses car là je sèche

  2. #2
    Membre chevronné Avatar de Er3van
    Homme Profil pro
    Architecte Logiciel
    Inscrit en
    Avril 2008
    Messages
    1 430
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Architecte Logiciel
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2008
    Messages : 1 430
    Points : 2 227
    Points
    2 227
    Par défaut
    Peux-tu nous montrer ton code qui génère l'exception ?

    Question bête : tu as bien le framework .Net 4.0 d'installé sur la machine qui fait tourner ce code?
    One minute was enough, Tyler said, a person had to work hard for it, but a minute of perfection was worth the effort. A moment was the most you could ever expect from perfection.

    -- Chuck Palahniuk, Fight Club, Chapter 3 --

  3. #3
    Candidat au Club
    Femme Profil pro
    Développeur .net
    Inscrit en
    Mai 2006
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 46
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur .net

    Informations forums :
    Inscription : Mai 2006
    Messages : 4
    Points : 4
    Points
    4
    Par défaut
    Oui j'ai bien le framework 4 installé.

    Le code est le suivant

    Code c# : 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
    using System.Data.Entity;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows.Forms;
    using System.Collections.ObjectModel;
     
    namespace CodeFirstSample
    {
        static class Program
        {
     
            static void Main(string[] args)
            {
                using (var db = new ProductContext())
                {
                    // Add a food category 
                    var food = new Category { CategoryId = "FOOD", Name = "Foods" };
                    db.Categories.Add(food);
                    int recordsAffected = db.SaveChanges();
     
                    Console.WriteLine(
                        "Saved {0} entities to the database, press any key to exit.",
                        recordsAffected);
     
                    Console.ReadKey();
                }
            }
     
        }
     
        public class Category
        {
            public string CategoryId { get; set; }
            public string Name { get; set; }
     
            public virtual ICollection<Product> Products { get; set; }
        }
     
        public class Product
        {
            public int ProductId { get; set; }
            public string Name { get; set; }
            public string CategoryId { get; set; }
     
            public virtual Category Category { get; set; }
        }
     
        public class ProductContext : DbContext
        {
            public DbSet<Category> Categories { get; set; }
            public DbSet<Product> Products { get; set; }
        }
    }
    ça plante donc direct sur db.Categories.Add(food);

Discussions similaires

  1. Problème de connection a SQL Server avec Entity Framework
    Par Korigoth dans le forum Développement Web avec .NET
    Réponses: 0
    Dernier message: 15/11/2014, 20h30
  2. Problème déploiement Application Web avec Entity FrameWork
    Par alenguard dans le forum Entity Framework
    Réponses: 2
    Dernier message: 07/03/2012, 17h25
  3. Problème Ajout Donnée avec Entity Framework
    Par Invité dans le forum Linq
    Réponses: 4
    Dernier message: 14/10/2009, 15h16
  4. Probleme de connexion avec Entities Framework
    Par gstrit dans le forum Général Dotnet
    Réponses: 4
    Dernier message: 09/06/2009, 10h09
  5. Problème SaveOrUpdate avec entity-name
    Par worldchampion57 dans le forum Hibernate
    Réponses: 5
    Dernier message: 11/04/2008, 13h06

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo