mercredi 3 juin 2015

Item added to DbContext twice

I am very new to SP.NET MVC, so excuse me for missing basic stuff.

I have created a website working with a database (Microsoft SQL Server) and I'm using Entity Framework package to manage it.

I have a DatabaseManager class as following:

Public class DatabaseManager : DbContext 
    Public DbSet<Connection> Connections { get; set; }

My application listens for syslog connections and then updates the Connections member accordingly:

Db.connections.Add(new Connection(SourceIp, DestinationIp))

Anyway, however weird it may seem, when I add a connection to the DbContext two connection are added (both identical) instead of one.

What might be my problem?

Aucun commentaire:

Enregistrer un commentaire