I am trying to check record , if exists declare to data with old one . But if doesnt then create a new one. Here is my code ;

```
var teamCheck= FootballerDBContext.Teams.Any(r => r.Name == teamName.Text.Trim());

if (teamCheck)
                {
                    team = FootballerDBContext.Teams.FirstOrDefault(c => c.Name == teamName.Text);

                }
FootballerDBContext.Teams.Add(team);
FootballerDBContext.SaveChanges(); // throwing exception right there . I did it exactly same to other entity everything was fine. 

```

Here is other entity , i did the same but Team throws exception. No errors here , doing what i want. It doesnt create new entity with new ID , just declaring old one.
( sponsor has many-to-many relationship , team has one-to-many )

```
var sponsorCheck = FootballerDBContext.Sponsors.Any(x => x.Name == Sponsor.Text.Trim());
if (sponsorCheck)
                    {
                        sponsor = FootballerDBContext.Sponsors.FirstOrDefault(z => z.Name == Sponsor.Text);

                    }

FootballerDBContext.FootballerSponsor.Add(fbsp);
                        FootballerDBContext.SaveChanges();

```