[Solved] Entity Framework c#

[ad_1]

The issue is with these 2 lines:

i2.Prodajalna.Add(new Prodajalna() { imeProdajalne = "Nekaj2", naslovProdajalne = "Koper" });
i3.Prodajalna.Add(new Prodajalna() { imeProdajalne = "Nekaj2", naslovProdajalne = "Koper" });

What you really want is to create a single Prodajalna and reuse it. The simplest way to accomplish this is to save the object first, and the re-use it.

var p = new Prodajalna() { imeProdajalne = "Nekaj2", naslovProdajalne = "Koper" };
_dbContext.Prodajalna.Add(p);
_dbContext.Save();

i2.Prodajalna.Add(p);
i3.Prodajalna.Add(p);

5

[ad_2]

solved Entity Framework c#