entity framework - EF6 database first - the relationship was not loaded because the type is not available -
i using ef6 database first design in web application. there 1 entity involved in 2 1-to-many relationships (the e2 in example):
e1 <--- e2 ---> e3
e1 , e3 both have navigation property e2 (called e2s). when try listview of e3, error listed in title. if remove navigation property e2 e3, works fine! i've tried looking on google no avail. help/direction appreciated.
added on 5/15:
tmg - hope wanting.
this 'e2' in example:
imports system imports system.collections.generic partial public class contact public property contact_id integer public property implementation_id integer public property contact_type_id integer public property name string public property user_id string public property is_main_contact boolean public property email_address string public overridable property contact_type contact_type public overridable property implementation implementation end class
the next 2 e1 , e3:
imports system imports system.collections.generic partial public class contact_type public property contact_type_id integer public property contact_type_description string public overridable property contacts icollection(of contact) = new hashset(of contact) end class
imports system imports system.collections.generic partial public class implementation public property implementation_id integer public property user_id string public property comments string public property creation_date nullable(of date) public property customer_name string public property customer_global_name string public property customer_address string public property customer_country string public property service_order_number string public property title string public property contact_name string public overridable property country country public overridable property supportdetail support_detail public overridable property tradecompliance trade_compliance public overridable property statuseffdates icollection(of implementation_status_eff_date) = new hashset(of implementation_status_eff_date) public overridable property hwsdata hws_data public overridable property documents icollection(of document) = new hashset(of document) public overridable property contacts icollection(of contact) = new hashset(of contact) end class
this list view code:
imports system.web.modelbinding public class implementationlist inherits system.web.ui.page protected sub page_load(byval sender object, byval e system.eventargs) handles me.load end sub public function getimplementations(<querystring("id")> categoryid system.nullable(of integer)) iqueryable(of implementation) dim db = new rfi_sdm.rfi_dataentities dim query iqueryable(of implementation) = db.implementations return query end function end class
and code rfi_dataentities:
imports system imports system.data.entity imports system.data.entity.infrastructure partial public class rfi_dataentities inherits dbcontext public sub new() mybase.new("name=rfi_dataentities") end sub protected overrides sub onmodelcreating(modelbuilder dbmodelbuilder) throw new unintentionalcodefirstexception() end sub public overridable property countries() dbset(of country) public overridable property implementations() dbset(of implementation) public overridable property replacement_type() dbset(of replacement_type) public overridable property service_level_choice() dbset(of service_level_choice) public overridable property support_detail() dbset(of support_detail) public overridable property tat_end_choice() dbset(of tat_end_choice) public overridable property tat_measurement_basis() dbset(of tat_measurement_basis) public overridable property tat_start_choice() dbset(of tat_start_choice) public overridable property regions() dbset(of region) public overridable property contacts() dbset(of contact) public overridable property contact_type() dbset(of contact_type) public overridable property hws_data() dbset(of hws_data) public overridable property implementation_mgr() dbset(of implementation_mgr) public overridable property implementation_service_level() dbset(of implementation_service_level) public overridable property implementation_status() dbset(of implementation_status) public overridable property implementation_status_eff_date() dbset(of implementation_status_eff_date) public overridable property trade_compliance() dbset(of trade_compliance) public overridable property implementation_type() dbset(of implementation_type) public overridable property documents() dbset(of document) public overridable property document_type() dbset(of document_type) public overridable property lcm_data() dbset(of lcm_data) public overridable property lcm_document() dbset(of lcm_document) end class
the actual error i'm getting is:
schema specified not valid. errors: relationship 'rfi_datamodel.fk_contact_contact_type' not loaded because type 'rfi_datamodel.contact' not available.
the relationship 'rfi_datamodel.fk_contact_implementation' not loaded because type 'rfi_datamodel.contact' not available.
if remove 'contact' navigation property contact_type , implementation classes, list view loads without issue.
Comments
Post a Comment