C# Entity Framework 6 DbContext System.Data.SqlClient.SqlException : The socket is not connected

-1

I'm a C# beginner; I tried to create a project with a local database using Entity Framework but I get this exception:

System.Data.SqlClient.SqlException (0x80131904): Unix Connect System.Net.Sockets.SocketException (0x80004005): The socket is not connected

Here is my DbContext class

namespace BibData
{
    public class BibContext : DbContext
    {
        public BibContext() : base("BibliothequeDB")
        {}

        public DbSet<Auteur> auteurs { get; set; } 
    }  
}

This is my program.cs

namespace BibConsole
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            BibContext ctx = new BibContext();

            Auteur auteur = new Auteur
            {
                auteurId = 1, nom = "x", prenom = "y"
            };

            ctx.auteurs.Add(auteur);

            ctx.SaveChanges();
        }
    }
}

and this is the exception

enter image description here

c#
asp.net
sql-server
entity-framework
asked on Stack Overflow Sep 22, 2018 by Haddad • edited Sep 22, 2018 by marc_s

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0