I have 3 entities in Sqlserver that I am mapping with the wizard of visual Studio
The three entities are packages categories and packages_categories,where packages_categ
In order to avoid creating new categories you must attach them to the context before you add the new package:
var _packagesContext=new DBPackages();
categoriesList.ForEach(c => _packagesContext.Categories.Attach(c));
_packagesContext.Add(new Packages {
packageSid="Sid blaaa.",
PackageName="TestPackage",
Categories=categoriesList
});