/// <summary> /// Initializes a new <see cref="EntityDataModel"/>. /// </summary> /// <param name="edmxDocument">The edmx file containing the model.</param> public EntityDataModel(XDocument edmxDocument) { _conceptualModel = edmxDocument?.Edm() ?? throw new ArgumentNullException(nameof(edmxDocument)); _conceptualTypeNamespace = _conceptualModel.Descendants("Schema") .Single() .Attribute("Namespace").Value; // The conceptual model entity type that is being mapped is specified by the // TypeName attribute of the EntityTypeMapping element. The table or view // that is being mapped is specified by the StoreEntitySet attribute of the // child MappingFragment element. _mappings = edmxDocument.Cs().Descendants("EntitySetMapping") .SelectMany(es => es.Cs().Elements("EntityTypeMapping")) .ToDictionary(et => Sanitize(et.Attribute("TypeName").Value), et => et.Cs().Element("MappingFragment") .Attribute("StoreEntitySet").Value); }