Hi,
I'm a newbie of database concept and Entity Framework. I'm creating a small application with the WPF technology; in this application I use a main window to display the datas that I can add with another window dialog. These datas are introduced in a database
(based to service) by various textboxes. Below my database structure:

I populate my database with this code in my dialog window:
dbDistintaEntities distinta = new dbDistintaEntities();
Societa soc = new Societa(){
ID = 1,
Nome = this.SquadraNome,
Campo = this.SquadraCampo,
Presidente = this.SquadraPres,
Allenatore = this.SquadraAll,
DirigenteAcc = "ilnulla",
DirigenteAr = "ilnulla",
Massaggiatore = "ilnulla",
Medico = "ilnulla",
};
this.distinta.AddToSocieta(soc);
this.distinta.SaveChanges();
So I can retrieve the previous datas in a main window with this code:
dbDistintaEntities distinta = new dbDistintaEntities();
var societa = distinta.Societa.ToList().Last();
SquadraNome = societa.Nome;
This implementation works well when I retrieve the datas when I return from dialog window while application is running but if I put the same code to retrieve the datas in a constructor of main window to load the data when the application is started I receive
this error:
'The invocation of the constructor on type 'DistintaProject.Views.MainWindow' that matches the specified binding constraints threw an exception.' Line number '6' and line position '9'.
I think that the problem is due to database is empty. To manage the window I use an Unity Container (to agree at MVVM pattern), I don't think that is a problem.
I don't understanding, anyone could help me?
Thank you!
LUCA