/// <summary>
 /// Deprecated Method for adding a new object to the Cities EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCities(City city)
 {
     base.AddObject("Cities", city);
 }
 /// <summary>
 /// Create a new City object.
 /// </summary>
 /// <param name="cityID">Initial value of the CityID property.</param>
 /// <param name="cityName">Initial value of the CityName property.</param>
 /// <param name="stateID">Initial value of the StateID property.</param>
 public static City CreateCity(global::System.Int32 cityID, global::System.String cityName, global::System.Int32 stateID)
 {
     City city = new City();
     city.CityID = cityID;
     city.CityName = cityName;
     city.StateID = stateID;
     return city;
 }
        private Int32 AddCity(string cityName, int stateId)
        {
            var cities = entities.Cities;
            foreach (var i in cities)
            {
                if (String.Equals(i.CityName.ToLower(), cityName.Trim().ToLower()))
                {
                    return i.CityID;
                }
            }
            City newCity = new City();
            newCity.CityName = cityName.Trim();
            newCity.StateID = stateId;

            entities.Cities.AddObject(newCity);
            entities.SaveChanges();
            return newCity.CityID;
        }