Sending data as application/JSON throws error - rest

I want to send data over the body as application/json. This is my request:
But with that I only get:
The #FormParam is utilized when the content type of the request entity
is not application/x-www-form-urlencoded
My Code:
<cffunction name="createInstance" access="remote" returntype="any" produces="application/json" httpmethod="POST" restpath="/instances">
<cfargument name="customerId" required="true" restArgSource="form" type="string" default=""/>
<cfargument name="name" required="true" restArgSource="form" type="string" default=""/>
<cfargument name="datasource" required="false" restArgSource="form" type="string" default=""/>
<cfargument name="startDate" required="true" restArgSource="form" type="string" default=""/>
<cfargument name="expirationDate" required="false" restArgSource="form" type="string" default=""/>
<cfargument name="amount" required="true" restArgSource="form" type="numeric" default=-1/>
<cfreturn name>
</cffunction>

Usually the JSON handlers should be used as GET method. Can you try with httpmethod as GET and restArgSource as path.
<cffunction name="createInstance"
access="remote"
returntype="any"
produces="application/json"
httpmethod="GET"
restpath="/instances">
<cfargument name="customerId" required="true"
restArgSource="Path" type="numeric" />
If you still need the request as POST, can you please share the headers tab?

Related

How to make Multiple word search in SOLRJQuery

I am currently working with SolrJ API for our webapplication. We need to have multiple word search in the application. But I do not know how to do it.
Here is the code we have developed so far by searching on the web.
HttpSolrClient solr = new HttpSolrClient("http://localhost:8983/solr/Test");
SolrQuery query = new SolrQuery();
query.setQuery("product_name:Dell laptop*");
query.setFields("product_name");
query.setStart(0);
query.setRows(1000);
QueryResponse response = solr.query(query);
SolrDocumentList results = response.getResults();
for (int i = 0; i < results.size(); ++i) {
System.out.println(results.get(i));
}
But I am not getting any result output. Our Solr has a mongo DB merged into it with the help of admin console of apache Solr which is running at 8983 port.
Please help. I am new to apache SOLR.
Update :
Here is the schema.xml we have created
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="example" version="1.5">
<field name="_version_" type="long" indexed="true" stored="true"/>
<field name="_root_" type="string" indexed="true" stored="false"/>
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="product_name" type="string" indexed="true" stored="true" required="true" multiValued="true"/>
<field name="product_url" type="string" indexed="true" stored="true" required="true" multiValued="true"/>
<field name="product_img" type="string" indexed="true" stored="true" required="true" multiValued="true"/>
<field name="product_price" type="double" indexed="true" stored="true" required="true" multiValued="true"/>
<dynamicField name="*_i" type="int" indexed="true" stored="true"/>
<dynamicField name="*_is" type="int" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_s" type="string" indexed="true" stored="true" />
<dynamicField name="*_ss" type="string" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_l" type="long" indexed="true" stored="true"/>
<dynamicField name="*_ls" type="long" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_t" type="text_general" indexed="true" stored="true"/>
<dynamicField name="*_txt" type="text_general" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_en" type="text_en" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_b" type="boolean" indexed="true" stored="true"/>
<dynamicField name="*_bs" type="boolean" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_f" type="float" indexed="true" stored="true"/>
<dynamicField name="*_fs" type="float" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_d" type="double" indexed="true" stored="true"/>
<dynamicField name="*_ds" type="double" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_coordinate" type="tdouble" indexed="true" stored="false" />
<dynamicField name="*_dt" type="date" indexed="true" stored="true"/>
<dynamicField name="*_dts" type="date" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="*_p" type="location" indexed="true" stored="true"/>
<dynamicField name="*_ti" type="tint" indexed="true" stored="true"/>
<dynamicField name="*_tl" type="tlong" indexed="true" stored="true"/>
<dynamicField name="*_tf" type="tfloat" indexed="true" stored="true"/>
<dynamicField name="*_td" type="tdouble" indexed="true" stored="true"/>
<dynamicField name="*_tdt" type="tdate" indexed="true" stored="true"/>
<dynamicField name="*_c" type="currency" indexed="true" stored="true"/>
<dynamicField name="ignored_*" type="ignored" multiValued="true"/>
<dynamicField name="attr_*" type="text_general" indexed="true" stored="true" multiValued="true"/>
<dynamicField name="random_*" type="random" />
<uniqueKey>id</uniqueKey>
<fieldType name="string" class="solr.StrField" sortMissingLast="true" />
<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="tint" class="solr.TrieIntField" precisionStep="8" positionIncrementGap="0"/>
<fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" positionIncrementGap="0"/>
<fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" positionIncrementGap="0"/>
<fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" positionIncrementGap="0"/>
<fieldType name="date" class="solr.TrieDateField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="tdate" class="solr.TrieDateField" precisionStep="6" positionIncrementGap="0"/>
<fieldType name="binary" class="solr.BinaryField"/>
<fieldType name="random" class="solr.RandomSortField" indexed="true" />
<fieldType name="text_ws" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
</analyzer>
</fieldType>
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<fieldType name="text_en" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="lang/stopwords_en.txt"
/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EnglishPossessiveFilterFactory"/>
<filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
<filter class="solr.PorterStemFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="lang/stopwords_en.txt"
/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EnglishPossessiveFilterFactory"/>
<filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
<filter class="solr.PorterStemFilterFactory"/>
</analyzer>
</fieldType>
<fieldType name="text_en_splitting" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="lang/stopwords_en.txt"
/>
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
<filter class="solr.PorterStemFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="lang/stopwords_en.txt"
/>
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
<filter class="solr.PorterStemFilterFactory"/>
</analyzer>
</fieldType>
<fieldType name="text_en_splitting_tight" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
<analyzer>
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="false"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="lang/stopwords_en.txt"/>
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="0" generateNumberParts="0" catenateWords="1" catenateNumbers="1" catenateAll="0"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
<filter class="solr.EnglishMinimalStemFilterFactory"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
</fieldType>
<fieldType name="text_general_rev" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.ReversedWildcardFilterFactory" withOriginal="true"
maxPosAsterisk="3" maxPosQuestion="2" maxFractionAsterisk="0.33"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<fieldType name="alphaOnlySort" class="solr.TextField" sortMissingLast="true" omitNorms="true">
<analyzer>
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.TrimFilterFactory" />
<filter class="solr.PatternReplaceFilterFactory"
pattern="([^a-z])" replacement="" replace="all"
/>
</analyzer>
</fieldType>
<fieldType name="lowercase" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory" />
</analyzer>
</fieldType>
<fieldType name="ignored" stored="false" indexed="false" multiValued="true" class="solr.StrField" />
<fieldType name="point" class="solr.PointType" dimension="2" subFieldSuffix="_d"/>
<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
geo="true" distErrPct="0.025" maxDistErr="0.001" distanceUnits="kilometers" />
<fieldType name="bbox" class="solr.BBoxField"
geo="true" distanceUnits="kilometers" numberType="_bbox_coord" />
<fieldType name="_bbox_coord" class="solr.TrieDoubleField" precisionStep="8" docValues="true" stored="false"/>
<fieldType name="currency" class="solr.CurrencyField" precisionStep="8" defaultCurrency="USD" currencyConfig="currency.xml" />
</schema>
And here is the data-config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<dataConfig>
<dataSource name="client_XXXX" type="MongoDataSource" database="client_XXXX" host="192.168.11.XXX" port="27017"/>
<document name="Titles">
<entity name="TitleEntity"
processor="MongoEntityProcessor"
query=""
collection="XXXX_data"
datasource="client_XXXX"
transformer="MongoMapperTransformer" >
<field column="product_name" name="product_name"/>
<field column="product_url" name="product_url"/>
<field column="product_img" name="product_img"/>
<field column="product_price" name="product_price"/>
<field column="_id" name="id"/>
</entity>
</document>
</dataConfig>
What you are running into is mentioned in Lucene's JavaDoc. Why Lucene? Solr's query syntax is a superset of Lucene's. As mentioned there
Note: The field is only valid for the term that it directly precedes, so the query
title:Do it right
Will only find "Do" in the title field. It will find "it" and "right" in the default field (in this case the text field).
In your case only Dell is directed to the field product_name, the rest is directed to the default search field defined in your configuration.
What you want to use to get around this is called Field Grouping. Therefore you need to surround the words that shall go to one field with round brackets, like this
SolrQuery query = new SolrQuery();
query.setQuery("product_name:(Dell laptop*)"); // surround the words with ( ... )
query.setFields("product_name");
query.setStart(0);
query.setRows(1000);
We created a new schema.xml by removing unwanted references here is the schema we used.
<schema name="example" version="1.5">
<field name="_version_" type="long" indexed="true" stored="true"/>
<field name="_root_" type="string" indexed="true" stored="false"/>
<fields>
<field name="id" type="long" indexed="true" stored="true" required="true" multiValued="false" />
<field name="product_name" type="string" indexed="true" stored="true" required="true" />
<field name="product_price" type="" indexed="true" stored="true" required="true" />
</fields>
<uniqueKey>id</uniqueKey>
<types>
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" omitNorms="true" positionIncrementGap="0" />
<fieldType name="text_wslc" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" positionIncrementGap="0"/>
<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
<fieldType name="tdate" class="solr.TrieDateField" omitNorms="true" precisionStep="6" positionIncrementGap="0"/>
<fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" positionIncrementGap="0"/>
</types>
<defaultSearchField>product_name</defaultSearchField>
<!-- we don't want too many results in this usecase -->
<solrQueryParser defaultOperator="AND"/>
</schema>

entity framework - inheritance design

Using .Net 4 with EF 1.0: I have a table per type inheritance database structure and edmx (see diagram and cutdown edmx at the end of the post. The edmx is created through a code generator). I've just included one subtype for this post but there are many!
All of our entity framework queries are also dynamically generated. So at the moment when I try to retrieve a product (which may or may not be a book) I have the following ESQL query being generated.
SELECT VALUE [tb_product] FROM [tb_product] as [tb_product] WHERE (([tb_product].[Id] = #p0))
If the object I've requested is a book, the object I'm getting returned to me is of type 'tb_product'. I can't seem to cast or otherwise access the 'book' information from this tb_product object.
How can I modify the query, edmx or some other component so that when I query the base type I can also access all relevant subtype information without a second database trip. Can I?
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="MyModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl">
<EntityContainer Name="MyModelStoreContainer">
<EntitySet Name="tb_productBook" EntityType="MyModel.Store.tb_productBook" store:Type="Tables" Schema="dbo" />
<EntitySet Name="tb_product" EntityType="MyModel.Store.tb_product" store:Type="Tables" Schema="dbo" />
<AssociationSet Name="FK_IdProductBook_Product" Association="MyModel.Store.FK_IdProductBook_Product">
<End Role="tb_product" EntitySet="tb_product" />
<End Role="tb_productBook" EntitySet="tb_productBook" />
</AssociationSet>
</EntityContainer>
<EntityType Name="tb_productBook">
<Key>
<PropertyRef Name="id" />
</Key>
<Property Name="id" Type="int" Nullable="false" />
<Property Name="title" Type="varchar" Nullable="false" MaxLength="150" />
<Property Name="subtitle" Type="varchar" Nullable="false" MaxLength="150" />
<Property Name="length" Type="int" Nullable="false" />
<Property Name="productCoverTypeId" Type="int" Nullable="false" />
<Property Name="volumeEdition" Type="varchar" Nullable="false" MaxLength="15" />
<Property Name="publisherName" Type="varchar" Nullable="false" MaxLength="100" />
<Property Name="publishDate" Type="datetime" />
<Property Name="iSBNNumber" Type="varchar" Nullable="false" MaxLength="30" />
<Property Name="description" Type="varchar" Nullable="false" />
<Property Name="authorBio" Type="varchar" Nullable="false" />
<Property Name="audience" Type="varchar" Nullable="false" />
<Property Name="expireDate" Type="datetime" />
<Property Name="vendorId" Type="int" Nullable="false" />
<Property Name="productCommissionTypeId" Type="int" Nullable="false" />
<Property Name="commissionValue" Type="decimal" Nullable="false" Precision="9" Scale="2" />
<Property Name="languageId" Type="int" Nullable="false" />
<Property Name="countryId" Type="int" Nullable="false" />
<Property Name="stateId" Type="int" Nullable="false" />
<Property Name="inventoryLocation" Type="varchar" Nullable="false" MaxLength="2000" />
</EntityType>
<EntityType Name="tb_product">
<Key>
<PropertyRef Name="id" />
</Key>
<Property Name="id" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="name" Type="varchar" MaxLength="100" />
<Property Name="productSku" Type="varchar" Nullable="false" MaxLength="17" />
<Property Name="productTypeId" Type="int" Nullable="false" />
<Property Name="price" Type="decimal" Nullable="false" Precision="9" Scale="2" />
<Property Name="marketOnWeb" Type="bit" Nullable="false" />
<Property Name="subsidiaryId" Type="int" Nullable="false" />
<Property Name="lmsProductId" Type="int" />
<Property Name="topicId" Type="int" />
<Property Name="categoryId" Type="int" />
<Property Name="eventId" Type="int" />
<Property Name="note" Type="varchar" />
<Property Name="expirationDate" Type="datetime" />
<Property Name="mediaLength" Type="int" />
<Property Name="urlSlug" Type="varchar" MaxLength="200" />
<Property Name="productSourceId" Type="int" />
<Property Name="created" Type="datetime" Nullable="false" />
<Property Name="createdBy" Type="varchar" Nullable="false" MaxLength="30" />
<Property Name="lastUpdated" Type="datetime" Nullable="false" />
<Property Name="lastUpdatedBy" Type="varchar" Nullable="false" MaxLength="30" />
</EntityType>
<Association Name="FK_IdProductBook_Product">
<End Role="tb_product" Type="MyModel.Store.tb_product" Multiplicity="1">
<OnDelete Action="Cascade" />
</End>
<End Role="tb_productBook" Type="MyModel.Store.tb_productBook" Multiplicity="0..1" />
<ReferentialConstraint>
<Principal Role="tb_product">
<PropertyRef Name="id" />
</Principal>
<Dependent Role="tb_productBook">
<PropertyRef Name="id" />
</Dependent>
</ReferentialConstraint>
</Association>
</Schema>
</edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="MyModel" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2006/04/edm">
<EntityContainer Name="MyEntities">
<EntitySet Name="tb_product" EntityType="MyModel.tb_product" />
</EntityContainer>
<EntityType Name="tb_productBook" BaseType="MyModel.tb_product">
<Property Name="title" Type="String" Nullable="false" />
<Property Name="subtitle" Type="String" Nullable="false" />
<Property Name="length" Type="Int32" Nullable="false" />
<Property Name="volumeEdition" Type="String" Nullable="false" />
<Property Name="publisherName" Type="String" Nullable="false" />
<Property Name="publishDate" Type="DateTime" Nullable="true" />
<Property Name="iSBNNumber" Type="String" Nullable="false" />
<Property Name="description" Type="String" Nullable="false" />
<Property Name="authorBio" Type="String" Nullable="false" />
<Property Name="audience" Type="String" Nullable="false" />
<Property Name="expireDate" Type="DateTime" Nullable="true" />
<Property Name="vendorId" Type="Int32" Nullable="false" />
<Property Name="commissionValue" Type="Decimal" Nullable="false" />
<Property Name="inventoryLocation" Type="String" Nullable="false" />
<NavigationProperty Name="ProductBook_Country" Relationship="MyModel.FK_CountryProductBook_Country" FromRole="tb_productBook" ToRole="tb_country" />
<NavigationProperty Name="ProductBook_Language" Relationship="MyModel.FK_LanguageProductBook_Language" FromRole="tb_productBook" ToRole="tb_language" />
<NavigationProperty Name="ProductBook_ProductCommissionType" Relationship="MyModel.FK_ProductCommissionTypeProductBook_ProductCommissionType" FromRole="tb_productBook" ToRole="tb_productCommissionType" />
<NavigationProperty Name="ProductBook_ProductCoverType" Relationship="MyModel.FK_ProductCoverTypeProductBook_ProductCoverType" FromRole="tb_productBook" ToRole="tb_productCoverType" />
<NavigationProperty Name="ProductBook_State" Relationship="MyModel.FK_StateProductBook_State" FromRole="tb_productBook" ToRole="tb_state" />
</EntityType>
<EntityType Name="tb_product">
<Key>
<PropertyRef Name="id" />
</Key>
<Property Name="id" Type="Int32" Nullable="false" />
<Property Name="name" Type="String" Nullable="true" />
<Property Name="productSku" Type="String" Nullable="false" />
<Property Name="price" Type="Decimal" Nullable="false" />
<Property Name="marketOnWeb" Type="Boolean" Nullable="false" />
<Property Name="subsidiaryId" Type="Int32" Nullable="false" />
<Property Name="lmsProductId" Type="Int32" Nullable="true" />
<Property Name="topicId" Type="Int32" Nullable="true" />
<Property Name="note" Type="String" Nullable="true" />
<Property Name="expirationDate" Type="DateTime" Nullable="true" />
<Property Name="mediaLength" Type="Int32" Nullable="true" />
<Property Name="urlSlug" Type="String" Nullable="true" />
<Property Name="created" Type="DateTime" Nullable="false" />
<Property Name="createdBy" Type="String" Nullable="false" />
<Property Name="lastUpdated" Type="DateTime" Nullable="false" />
<Property Name="lastUpdatedBy" Type="String" Nullable="false" />
<NavigationProperty Name="CampaignAdvertisedProduct_Product" Relationship="MyModel.FK_ProductCampaignAdvertisedProduct_Product" FromRole="tb_product" ToRole="tb_campaignAdvertisedProduct" />
<NavigationProperty Name="DiscountGroupProduct_Product" Relationship="MyModel.FK_ProductDiscountGroupProduct_Product" FromRole="tb_product" ToRole="tb_discountGroupProduct" />
<NavigationProperty Name="LogCampaignResponseUpdate_Product" Relationship="MyModel.FK_ProductLogCampaignResponseUpdate_Product" FromRole="tb_product" ToRole="tb_logCampaignResponseUpdate" />
<NavigationProperty Name="ProductAuthor_Product" Relationship="MyModel.FK_ProductProductAuthor_Product" FromRole="tb_product" ToRole="tb_productAuthor" />
<NavigationProperty Name="ProductImage_Product" Relationship="MyModel.FK_ProductProductImage_Product" FromRole="tb_product" ToRole="tb_productImage" />
<NavigationProperty Name="ProductMarketingContent_Product" Relationship="MyModel.FK_ProductProductMarketingContent_Product" FromRole="tb_product" ToRole="tb_productMarketingContent" />
<NavigationProperty Name="ProductOnsiteStaffAgency_Product" Relationship="MyModel.FK_ProductProductOnsiteStaffAgency_Product" FromRole="tb_product" ToRole="tb_productOnsiteStaffAgency" />
<NavigationProperty Name="ProductProblem_Product" Relationship="MyModel.FK_ProductProductProblem_Product" FromRole="tb_product" ToRole="tb_productProblem" />
<NavigationProperty Name="ProductVenue_Product" Relationship="MyModel.FK_ProductProductVenue_Product" FromRole="tb_product" ToRole="tb_productVenue" />
<NavigationProperty Name="VenueEmailRequest_Product" Relationship="MyModel.FK_ProductVenueEmailRequest_Product" FromRole="tb_product" ToRole="tb_venueEmailRequest" />
<NavigationProperty Name="Product_Category" Relationship="MyModel.FK_CategoryProduct_Category" FromRole="tb_product" ToRole="tb_category" />
<NavigationProperty Name="Product_ProductSource" Relationship="MyModel.FK_ProductSourceProduct_ProductSource" FromRole="tb_product" ToRole="tb_productSource" />
<NavigationProperty Name="Product_ProductType" Relationship="MyModel.FK_ProductTypeProduct_ProductType" FromRole="tb_product" ToRole="tb_productType" />
<NavigationProperty Name="Product_Event" Relationship="MyModel.FK_EventProduct_Event" FromRole="tb_product" ToRole="tb_event" />
<NavigationProperty Name="tb_category" Relationship="MyModel.tb_product_category" FromRole="tb_product" ToRole="tb_category" />
<NavigationProperty Name="tb_contact" Relationship="MyModel.tb_product_faculty" FromRole="tb_product" ToRole="tb_contact" />
<NavigationProperty Name="tb_state" Relationship="MyModel.tb_product_State" FromRole="tb_product" ToRole="tb_state" />
<NavigationProperty Name="tb_vendorCost" Relationship="MyModel.tb_product_VendorCost" FromRole="tb_product" ToRole="tb_vendorCost" />
<NavigationProperty Name="tb_vendorInvoice" Relationship="MyModel.tb_product_VendorInvoice" FromRole="tb_product" ToRole="tb_vendorInvoice" />
<NavigationProperty Name="tb_vendorPayment" Relationship="MyModel.tb_product_VendorPayment" FromRole="tb_product" ToRole="tb_vendorPayment" />
</EntityType>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping Space="C-S" xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS">
<EntityContainerMapping StorageEntityContainer="MyModelStoreContainer" CdmEntityContainer="MyEntities">
<EntitySetMapping Name="tb_product">
<EntityTypeMapping TypeName="IsTypeOf(MyModel.tb_product)">
<MappingFragment StoreEntitySet="tb_product">
<ScalarProperty Name="lastUpdatedBy" ColumnName="lastUpdatedBy" />
<ScalarProperty Name="lastUpdated" ColumnName="lastUpdated" />
<ScalarProperty Name="createdBy" ColumnName="createdBy" />
<ScalarProperty Name="created" ColumnName="created" />
<ScalarProperty Name="urlSlug" ColumnName="urlSlug" />
<ScalarProperty Name="mediaLength" ColumnName="mediaLength" />
<ScalarProperty Name="expirationDate" ColumnName="expirationDate" />
<ScalarProperty Name="note" ColumnName="note" />
<ScalarProperty Name="topicId" ColumnName="topicId" />
<ScalarProperty Name="lmsProductId" ColumnName="lmsProductId" />
<ScalarProperty Name="subsidiaryId" ColumnName="subsidiaryId" />
<ScalarProperty Name="marketOnWeb" ColumnName="marketOnWeb" />
<ScalarProperty Name="price" ColumnName="price" />
<ScalarProperty Name="productSku" ColumnName="productSku" />
<ScalarProperty Name="name" ColumnName="name" />
<ScalarProperty Name="id" ColumnName="id" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="IsTypeOf(MyModel.tb_productBook)">
<MappingFragment StoreEntitySet="tb_productBook">
<ScalarProperty Name="inventoryLocation" ColumnName="inventoryLocation" />
<ScalarProperty Name="commissionValue" ColumnName="commissionValue" />
<ScalarProperty Name="vendorId" ColumnName="vendorId" />
<ScalarProperty Name="expireDate" ColumnName="expireDate" />
<ScalarProperty Name="audience" ColumnName="audience" />
<ScalarProperty Name="authorBio" ColumnName="authorBio" />
<ScalarProperty Name="description" ColumnName="description" />
<ScalarProperty Name="iSBNNumber" ColumnName="iSBNNumber" />
<ScalarProperty Name="publishDate" ColumnName="publishDate" />
<ScalarProperty Name="publisherName" ColumnName="publisherName" />
<ScalarProperty Name="volumeEdition" ColumnName="volumeEdition" />
<ScalarProperty Name="length" ColumnName="length" />
<ScalarProperty Name="subtitle" ColumnName="subtitle" />
<ScalarProperty Name="title" ColumnName="title" />
<ScalarProperty Name="id" ColumnName="id" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>

Entity Framework Error 3021: mapped to multiple conceptual side properties

I Have a table for Authors with a PK AuthorID.
I then have a table called AuthoritativeAuthors with a PK AuthorID.
AuthoritativeAuthor.AuthorID is a Foreign key pointing to Authors.AuthorID.
An AuthorID in Authors may or may not appear in AuthoritativeAuthors.
Here is the error I'm getting
Error 3021: Problem in mapping fragments starting at line 4365:Each of the following columns in table AuthoritativeAuthors is mapped to multiple conceptual side properties:
AuthoritativeAuthors.AuthorID is mapped to <FK_AuthoritativeAuthors_Authors.AuthoritativeAuthor.AuthorID, FK_AuthoritativeAuthors_Authors.Author.AuthorID>
Here is all the code in the edmx that seems relevant.
Storage Models
<EntityType Name="Authors">
<Key>
<PropertyRef Name="AuthorID" />
</Key>
<Property Name="AuthorID" Type="int" Nullable="false" />
<Property Name="Name" Type="nvarchar" MaxLength="254" />
</EntityType>
<EntityType Name="AuthoritativeAuthors">
<Key>
<PropertyRef Name="AuthorID" />
</Key>
<Property Name="AuthoritativeAuthorID" Type="int" Nullable="false" />
<Property Name="AuthorID" Type="int" Nullable="false" />
</EntityType>
<Association Name="FK_AuthoritativeAuthors_Authors">
<End Role="AuthoritativeAuthor" Type="WCDBModel.Store.AuthoritativeAuthors" Multiplicity="0..1" />
<End Role="Author" Type="WCDBModel.Store.Authors" Multiplicity="1" />
<ReferentialConstraint>
<Principal Role="Author">
<PropertyRef Name="AuthorID" />
</Principal>
<Dependent Role="AuthoritativeAuthor">
<PropertyRef Name="AuthorID" />
</Dependent>
</ReferentialConstraint>
</Association>
Conceptual Models
<EntitySet Name="AuthorSet" EntityType="WCDBModel.Author" />
<EntitySet Name="AuthoritativeAuthorSet" EntityType="WCDBModel.AuthoritativeAuthor" />
<AssociationSet Name="FK_AuthoritativeAuthors_Authors" Association="WCDBModel.FK_AuthoritativeAuthors_Authors">
<End Role="Author" EntitySet="AuthorSet" />
<End Role="AuthoritativeAuthor" EntitySet="AuthoritativeAuthorSet" />
</AssociationSet>
<EntityType Name="Author">
<Key>
<PropertyRef Name="AuthorID" />
</Key>
<Property Name="AuthorID" Type="Int32" Nullable="false" />
<Property Name="Name" Type="String" Nullable="true" />
<NavigationProperty Name="AuthoritativeAuthors" Relationship="WCDBModel.FK_AuthoritativeAuthors_Authors" FromRole="Author" ToRole="AuthoritativeAuthor" />
</EntityType>
<Association Name="FK_AuthoritativeAuthors_Authors">
<End Type="WCDBModel.Author" Role="Author" Multiplicity="1" />
<End Type="WCDBModel.AuthoritativeAuthor" Role="AuthoritativeAuthor" Multiplicity="0..1" />
</Association>
<EntityType Name="AuthoritativeAuthor">
<Key>
<PropertyRef Name="AuthorID" />
</Key>
<Property Type="Int32" Name="AuthorID" Nullable="false" />
<Property Type="Int32" Name="AuthoritativeAuthorID" Nullable="false" />
<NavigationProperty Name="Author" Relationship="WCDBModel.FK_AuthoritativeAuthors_Authors" FromRole="AuthoritativeAuthor" ToRole="Author" />
</EntityType>
Mapping
<EntitySetMapping Name="AuthorSet">
<EntityTypeMapping TypeName="IsTypeOf(WCDBModel.Author)">
<MappingFragment StoreEntitySet="Authors">
<ScalarProperty Name="Name" ColumnName="Name" />
<ScalarProperty Name="AuthorID" ColumnName="AuthorID" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="AuthoritativeAuthorSet">
<EntityTypeMapping TypeName="IsTypeOf(WCDBModel.AuthoritativeAuthor)">
<MappingFragment StoreEntitySet="AuthoritativeAuthors">
<ScalarProperty Name="AuthoritativeAuthorID" ColumnName="AuthoritativeAuthorID"/>
<ScalarProperty Name="AuthorID" ColumnName="AuthorID" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<AssociationSetMapping Name="FK_AuthoritativeAuthors_Authors" TypeName="WCDBModel.FK_AuthoritativeAuthors_Authors" StoreEntitySet="AuthoritativeAuthors">
<EndProperty Name="AuthoritativeAuthor">
<ScalarProperty Name="AuthorID" ColumnName="AuthorID" />
</EndProperty>
<EndProperty Name="Author">
<ScalarProperty Name="AuthorID" ColumnName="AuthorID" />
</EndProperty>
<Condition ColumnName="AuthorID" IsNull="false" />
</AssociationSetMapping>
Any assistance in finding the cause of this error would be appreciated.
I ended up creating a dummy primary key in my AuthoritativeAuthor table that was not also a foreign key.

Firebird .NET Provider 2.7.5: Value cannot be null. Parameter name: key

This worked with Firebird .NET Provider 2.6.5:
using (var context = new SetupContext())
{
_maxApplicationID = context.Application.Max(a => (int?)a.ID) ?? 0;
}
Table Mapping:
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="Model1.Store" Alias="Self" Provider="FirebirdSql.Data.FirebirdClient" ProviderManifestToken="2.5" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
<EntityContainer Name="Model1StoreContainer">
<EntitySet Name="APPLICATION" EntityType="Model1.Store.APPLICATION" store:Type="Tables" Schema="Firebird" />
</EntityContainer>
<EntityType Name="APPLICATION">
<Key>
<PropertyRef Name="ID" />
</Key>
<Property Name="ID" Type="int" Nullable="false" />
<Property Name="NAME" Type="varchar" Nullable="false" MaxLength="50" />
<Property Name="DISPLAY_TEXT" Type="varchar" MaxLength="255" />
<Property Name="ARGUMENTS" Type="varchar" MaxLength="255" />
<Property Name="PATH" Type="varchar" MaxLength="255" />
<Property Name="TYPE" Type="char" MaxLength="1" />
</EntityType>
</Schema>
</edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="Model1" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityContainer Name="Entities" annotation:LazyLoadingEnabled="true">
<EntitySet Name="Application" EntityType="Model1.Application" />
</EntityContainer>
<EntityType Name="Application">
<Key>
<PropertyRef Name="ID" />
</Key>
<Property Name="ID" Type="Int32" Nullable="false" />
<Property Name="Name" Type="String" Nullable="false" MaxLength="50" Unicode="true" FixedLength="false" />
<Property Name="DisplayText" Type="String" MaxLength="255" Unicode="true" FixedLength="false" />
<Property Name="Arguments" Type="String" MaxLength="255" Unicode="true" FixedLength="false" />
<Property Name="Path" Type="String" MaxLength="255" Unicode="true" FixedLength="false" />
<Property Name="Type" Type="String" MaxLength="1" Unicode="true" FixedLength="true" />
</EntityType>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs">
<EntityContainerMapping StorageEntityContainer="Model1StoreContainer" CdmEntityContainer="Entities">
<EntitySetMapping Name="Application"><EntityTypeMapping TypeName="Model1.Application"><MappingFragment StoreEntitySet="APPLICATION">
<ScalarProperty Name="ID" ColumnName="ID" />
<ScalarProperty Name="Name" ColumnName="NAME" />
<ScalarProperty Name="DisplayText" ColumnName="DISPLAY_TEXT" />
<ScalarProperty Name="Arguments" ColumnName="ARGUMENTS" />
<ScalarProperty Name="Path" ColumnName="PATH" />
<ScalarProperty Name="Type" ColumnName="TYPE" />
</MappingFragment></EntityTypeMapping></EntitySetMapping>
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
Now I have upgraded to version Firebird .NET Provider 2.7.5 and I'm getting an ArgumentNullException saying that "Value cannot be null. Parameter name: key".
Is this a changed behaviour in 2.7.5 or did somthing went wrong with the update. If this is a changed behaviour: How can I get the maximum value of a column?
If done as Mark Rotteveel suggested. This is the link to the ticket in the firebird bug database: http://tracker.firebirdsql.org/browse/DNET-429

Entity Framework Add Mapping to View

Our app. has a complex set of security rules.
I've implemented the rules in a SQL Statement, then translated it to Linq to SQL and the Entity Framework. the EF one was having some performance issues due to the nature of follow-up queries that have to take place on the data set, so I figured it would be best to just have the filtering done in SQL where I have maximum control over the statement that is executed, to ensure performance. I fit it in a View, thinking I'd let EF use that as a basis & continue the rest of the filtering there, but I am having trouble mapping the existing tables to the view.
As you can see on the screenshot, all three columns are identified as Entity Key. The problem is that I can't define a FK for a View, so EF doesn't know how the connections are to be made. When I try to manualy create them, EF complains I need to specify a connection to all three columns (for a single relation), which is not possible. I've also tried it from the other end, but no dice.
Here's the .edmx:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
<!-- EF Runtime content -->
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="VPModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
<EntityContainer Name="VPModelStoreContainer">
<EntitySet Name="entity" EntityType="VPModel.Store.entity" store:Type="Tables" Schema="dbo" />
<EntitySet Name="entity_type" EntityType="VPModel.Store.entity_type" store:Type="Tables" Schema="dbo" />
<EntitySet Name="user" EntityType="VPModel.Store.user" store:Type="Tables" Schema="dbo" />
<EntitySet Name="vwEntitiesFilteredOnSecurity" EntityType="VPModel.Store.vwEntitiesFilteredOnSecurity" store:Type="Views" store:Schema="dbo" store:Name="vwEntitiesFilteredOnSecurity">
<DefiningQuery>SELECT
[vwEntitiesFilteredOnSecurity].[id] AS [id],
[vwEntitiesFilteredOnSecurity].[type_id] AS [type_id],
[vwEntitiesFilteredOnSecurity].[user_id] AS [user_id]
FROM [dbo].[vwEntitiesFilteredOnSecurity] AS [vwEntitiesFilteredOnSecurity]</DefiningQuery>
</EntitySet>
<AssociationSet Name="FK_entity_entity" Association="VPModel.Store.FK_entity_entity">
<End Role="entity" EntitySet="entity" />
<End Role="entity1" EntitySet="entity" />
</AssociationSet>
<AssociationSet Name="FK_entity_entity_type" Association="VPModel.Store.FK_entity_entity_type">
<End Role="entity_type" EntitySet="entity_type" />
<End Role="entity" EntitySet="entity" />
</AssociationSet>
<AssociationSet Name="FK_entity_user" Association="VPModel.Store.FK_entity_user">
<End Role="user" EntitySet="user" />
<End Role="entity" EntitySet="entity" />
</AssociationSet>
<AssociationSet Name="FK_user_user" Association="VPModel.Store.FK_user_user">
<End Role="user" EntitySet="user" />
<End Role="user1" EntitySet="user" />
</AssociationSet>
</EntityContainer>
<EntityType Name="entity">
<Key>
<PropertyRef Name="id" />
</Key>
<Property Name="id" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="name" Type="varchar" Nullable="false" MaxLength="200" />
<Property Name="creator_id" Type="int" />
<Property Name="type_id" Type="int" Nullable="false" />
<Property Name="parent_id" Type="int" />
</EntityType>
<EntityType Name="entity_type">
<Key>
<PropertyRef Name="id" />
</Key>
<Property Name="id" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="name" Type="varchar" Nullable="false" MaxLength="150" />
</EntityType>
<EntityType Name="user">
<Key>
<PropertyRef Name="id" />
</Key>
<Property Name="id" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="name" Type="varchar" Nullable="false" MaxLength="250" />
</EntityType>
<!--Errors Found During Generation:
warning 6002: The table/view 'mi7demo.dbo.vwEntitiesFilteredOnSecurity' does not have a primary key defined. The key has been inferred and the definition was created as a read-only table/view.
-->
<EntityType Name="vwEntitiesFilteredOnSecurity">
<Key>
<PropertyRef Name="id" />
<PropertyRef Name="type_id" />
<PropertyRef Name="user_id" />
</Key>
<Property Name="id" Type="int" Nullable="false" />
<Property Name="type_id" Type="int" Nullable="false" />
<Property Name="user_id" Type="int" Nullable="false" />
</EntityType>
<Association Name="FK_entity_entity">
<End Role="entity" Type="VPModel.Store.entity" Multiplicity="0..1" />
<End Role="entity1" Type="VPModel.Store.entity" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="entity">
<PropertyRef Name="id" />
</Principal>
<Dependent Role="entity1">
<PropertyRef Name="parent_id" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_entity_entity_type">
<End Role="entity_type" Type="VPModel.Store.entity_type" Multiplicity="1">
<OnDelete Action="Cascade" />
</End>
<End Role="entity" Type="VPModel.Store.entity" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="entity_type">
<PropertyRef Name="id" />
</Principal>
<Dependent Role="entity">
<PropertyRef Name="type_id" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_entity_user">
<End Role="user" Type="VPModel.Store.user" Multiplicity="0..1" />
<End Role="entity" Type="VPModel.Store.entity" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="user">
<PropertyRef Name="id" />
</Principal>
<Dependent Role="entity">
<PropertyRef Name="creator_id" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_user_user">
<End Role="user" Type="VPModel.Store.user" Multiplicity="1" />
<End Role="user1" Type="VPModel.Store.user" Multiplicity="0..1" />
<ReferentialConstraint>
<Principal Role="user">
<PropertyRef Name="id" />
</Principal>
<Dependent Role="user1">
<PropertyRef Name="id" />
</Dependent>
</ReferentialConstraint>
</Association>
</Schema>
</edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="VPModel" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityContainer Name="VP" annotation:LazyLoadingEnabled="true">
<EntitySet Name="entity" EntityType="VPModel.entity" />
<EntitySet Name="entity_type" EntityType="VPModel.entity_type" />
<EntitySet Name="user" EntityType="VPModel.user" />
<EntitySet Name="vwEntitiesFilteredOnSecurity" EntityType="VPModel.vwEntitiesFilteredOnSecurity" />
<AssociationSet Name="FK_entity_entity" Association="VPModel.FK_entity_entity">
<End EntitySet="entity" Role="entity" />
<End EntitySet="entity" Role="entity1" />
</AssociationSet>
<AssociationSet Name="FK_entity_entity_type" Association="VPModel.FK_entity_entity_type">
<End Role="entity_type" EntitySet="entity_type" />
<End Role="entity" EntitySet="entity" />
</AssociationSet>
<AssociationSet Name="FK_entity_user" Association="VPModel.FK_entity_user">
<End Role="user" EntitySet="user" />
<End Role="entity" EntitySet="entity" />
</AssociationSet>
<AssociationSet Name="FK_user_user" Association="VPModel.FK_user_user">
<End Role="user" EntitySet="user" />
<End Role="user1" EntitySet="user" />
</AssociationSet>
</EntityContainer>
<EntityType Name="entity">
<Key>
<PropertyRef Name="id" />
</Key>
<Property Name="id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="name" Type="String" Nullable="false" MaxLength="200" Unicode="false" FixedLength="false" />
<Property Name="creator_id" Type="Int32" />
<Property Name="type_id" Type="Int32" Nullable="false" />
<Property Name="parent_id" Type="Int32" />
<NavigationProperty Name="entity1" Relationship="VPModel.FK_entity_entity" FromRole="entity" ToRole="entity1" />
<NavigationProperty Name="entity2" Relationship="VPModel.FK_entity_entity" FromRole="entity1" ToRole="entity" />
<NavigationProperty Name="entity_type" Relationship="VPModel.FK_entity_entity_type" FromRole="entity" ToRole="entity_type" />
<NavigationProperty Name="user" Relationship="VPModel.FK_entity_user" FromRole="entity" ToRole="user" />
</EntityType>
<EntityType Name="entity_type">
<Key>
<PropertyRef Name="id" />
</Key>
<Property Name="id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="name" Type="String" Nullable="false" MaxLength="150" Unicode="false" FixedLength="false" />
<NavigationProperty Name="entity" Relationship="VPModel.FK_entity_entity_type" FromRole="entity_type" ToRole="entity" />
</EntityType>
<EntityType Name="user">
<Key>
<PropertyRef Name="id" />
</Key>
<Property Name="id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="name" Type="String" Nullable="false" MaxLength="250" Unicode="false" FixedLength="false" />
<NavigationProperty Name="entity" Relationship="VPModel.FK_entity_user" FromRole="user" ToRole="entity" />
<NavigationProperty Name="user1" Relationship="VPModel.FK_user_user" FromRole="user" ToRole="user1" />
<NavigationProperty Name="user2" Relationship="VPModel.FK_user_user" FromRole="user1" ToRole="user" />
</EntityType>
<EntityType Name="vwEntitiesFilteredOnSecurity">
<Key>
<PropertyRef Name="id" />
<PropertyRef Name="type_id" />
<PropertyRef Name="user_id" />
</Key>
<Property Name="id" Type="Int32" Nullable="false" />
<Property Name="type_id" Type="Int32" Nullable="false" />
<Property Name="user_id" Type="Int32" Nullable="false" />
</EntityType>
<Association Name="FK_entity_entity">
<End Type="VPModel.entity" Multiplicity="0..1" Role="entity" />
<End Type="VPModel.entity" Multiplicity="*" Role="entity1" />
<ReferentialConstraint>
<Principal Role="entity">
<PropertyRef Name="id" />
</Principal>
<Dependent Role="entity1">
<PropertyRef Name="parent_id" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_entity_entity_type">
<End Role="entity_type" Type="VPModel.entity_type" Multiplicity="1">
<OnDelete Action="Cascade" />
</End>
<End Role="entity" Type="VPModel.entity" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="entity_type">
<PropertyRef Name="id" />
</Principal>
<Dependent Role="entity">
<PropertyRef Name="type_id" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_entity_user">
<End Role="user" Type="VPModel.user" Multiplicity="0..1" />
<End Role="entity" Type="VPModel.entity" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="user">
<PropertyRef Name="id" />
</Principal>
<Dependent Role="entity">
<PropertyRef Name="creator_id" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_user_user">
<End Role="user" Type="VPModel.user" Multiplicity="1" />
<End Role="user1" Type="VPModel.user" Multiplicity="0..1" />
<ReferentialConstraint>
<Principal Role="user">
<PropertyRef Name="id" />
</Principal>
<Dependent Role="user1">
<PropertyRef Name="id" />
</Dependent>
</ReferentialConstraint>
</Association>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs">
<EntityContainerMapping StorageEntityContainer="VPModelStoreContainer" CdmEntityContainer="VP">
<EntitySetMapping Name="entity"><EntityTypeMapping TypeName="VPModel.entity"><MappingFragment StoreEntitySet="entity">
<ScalarProperty Name="id" ColumnName="id" />
<ScalarProperty Name="name" ColumnName="name" />
<ScalarProperty Name="creator_id" ColumnName="creator_id" />
<ScalarProperty Name="type_id" ColumnName="type_id" />
<ScalarProperty Name="parent_id" ColumnName="parent_id" />
</MappingFragment></EntityTypeMapping></EntitySetMapping>
<EntitySetMapping Name="entity_type"><EntityTypeMapping TypeName="VPModel.entity_type"><MappingFragment StoreEntitySet="entity_type">
<ScalarProperty Name="id" ColumnName="id" />
<ScalarProperty Name="name" ColumnName="name" />
</MappingFragment></EntityTypeMapping></EntitySetMapping>
<EntitySetMapping Name="user"><EntityTypeMapping TypeName="VPModel.user"><MappingFragment StoreEntitySet="user">
<ScalarProperty Name="id" ColumnName="id" />
<ScalarProperty Name="name" ColumnName="name" />
</MappingFragment></EntityTypeMapping></EntitySetMapping>
<EntitySetMapping Name="vwEntitiesFilteredOnSecurity"><EntityTypeMapping TypeName="VPModel.vwEntitiesFilteredOnSecurity"><MappingFragment StoreEntitySet="vwEntitiesFilteredOnSecurity">
<ScalarProperty Name="id" ColumnName="id" />
<ScalarProperty Name="type_id" ColumnName="type_id" />
<ScalarProperty Name="user_id" ColumnName="user_id" />
</MappingFragment></EntityTypeMapping></EntitySetMapping>
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
</edmx:Runtime>
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
<Designer xmlns="http://schemas.microsoft.com/ado/2008/10/edmx">
<Connection>
<DesignerInfoPropertySet>
<DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
</DesignerInfoPropertySet>
</Connection>
<Options>
<DesignerInfoPropertySet>
<DesignerProperty Name="ValidateOnBuild" Value="true" />
<DesignerProperty Name="EnablePluralization" Value="False" />
<DesignerProperty Name="IncludeForeignKeysInModel" Value="True" />
</DesignerInfoPropertySet>
</Options>
<!-- Diagram content (shape and connector positions) -->
<Diagrams>
<Diagram Name="ViewProblem">
<EntityTypeShape EntityType="VPModel.entity" Width="1.5" PointX="3" PointY="3.75" Height="2.7494921874999987" IsExpanded="true" />
<EntityTypeShape EntityType="VPModel.entity_type" Width="1.5" PointX="0.75" PointY="5.875" Height="1.5956835937499996" IsExpanded="true" />
<EntityTypeShape EntityType="VPModel.user" Width="1.5" PointX="0.75" PointY="0.75" Height="1.9802864583333331" IsExpanded="true" />
<EntityTypeShape EntityType="VPModel.vwEntitiesFilteredOnSecurity" Width="1.5" PointX="5.75" PointY="3.25" Height="1.5956835937499996" IsExpanded="true" />
<AssociationConnector ManuallyRouted="false" Association="VPModel.FK_entity_entity">
<ConnectorPoint PointX="3.5319230769230767" PointY="6.4994921874999987" />
<ConnectorPoint PointX="3.5319230769230767" PointY="6.7494921875" />
<ConnectorPoint PointX="3.9784615384615383" PointY="6.7494921875" />
<ConnectorPoint PointX="3.9784615384615383" PointY="6.4994921874999987" />
</AssociationConnector>
<AssociationConnector Association="VPModel.FK_entity_entity_type" ManuallyRouted="false">
<ConnectorPoint PointX="2.25" PointY="6.18724609375" />
<ConnectorPoint PointX="3" PointY="6.18724609375" />
</AssociationConnector>
<AssociationConnector Association="VPModel.FK_entity_user" ManuallyRouted="false">
<ConnectorPoint PointX="2.25" PointY="1.7401432291666663" />
<ConnectorPoint PointX="3.75" PointY="1.7401432291666663" />
<ConnectorPoint PointX="3.75" PointY="3.75" />
</AssociationConnector>
<AssociationConnector Association="VPModel.FK_user_user" ManuallyRouted="false">
<ConnectorPoint PointX="1.2819230769230767" PointY="2.7302864583333331" />
<ConnectorPoint PointX="1.2819230769230767" PointY="2.9802864583333331" />
<ConnectorPoint PointX="1.7284615384615383" PointY="2.9802864583333331" />
<ConnectorPoint PointX="1.7284615384615383" PointY="2.7302864583333331" />
</AssociationConnector>
</Diagram>
</Diagrams>
</Designer>
</edmx:Edmx>
In the vwEntitiesFilter just click the field id, right click properties and in the properties window set "Entity Key" = false
Then in toolbox, chose association and associate user.id field with vwEntitiesFilter.user_id and entity.id with vwEntitiesFilter.entity_id.
This just allow you to make the relations