i trying figure out how seed complex entity framework code first object. code have allows me insert simple objects there has way more complex items, i.e. address adresstype field.
context.addresstypes.addorupdate( p => p.name, new addresstype { name = "original" }, new addresstype { name = "shipping" }, new addresstype { name = "billing" } ); context.addresses.addorupdate( => a.address1, new address { address1 = "1234 west main", city = "hannibal", region = "mo", postalcode = "12345", country = "usa", type = context.addresstypes.where(a=>a.name=="original") });
but while can "find" addresstype id can't "where" name equals. find work except can not guarantee id each seed , want base on name instead.
any suggestions on how this? tia
solution: added reference system.linq seed class. able clause.
Comments
Post a Comment