c# - Finding or creating an object in Entity Framework -
my domain model , associations follows: customer has many region s region has many location s our client supplies csv file has following columns: customer name region name location name latitude longitude ... based on information, have find or create customer name, find or create region name, , find or update location name. i have tried following: var customer = c in _data.customer c.name == cells[0] select c; if (customer == null) customer = new customer(...); i follow same pattern finding or creating/updating region , location, however, problem run type of linq query cannot converted customer -object on line customer = new customers(); . need reference customer object later can't have 2 separate variables. how accomplish in entity framework? this code var customer = c in _data.customer c.name == cells[0] select c; returns customers has name equals cells[0] return type...