SAPUI5 - mockup server - sapui5

I'm following this Mockup Server tutorial for SAPUI5. But I'm not able to retrieve the data and set it to my model. Here's what I do:
I have slightly changed the data so, so two things have to be changed:
json data - Person.json:
{ "id":1,
"first_name":"Chris",
"last_name":"Johnston", "email":"cjohnston0#dailymotion.com", "gender":"Male", "ip_address":"119.220.205.173" }
emphasized text
``
<edmx:Edmx Version="1.0"
xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"/>
<edmx:DataServices m:DataServiceVersion="1.0"
m:MaxDataServiceVersion="3.0">
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<Schema Namespace="PersonsData" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityType Name="Person">
<Key>
<PropertyRef Name="id"/>
</Key>
<Property name="id" Type="Edm.Int16" Nullable="false" />
<Property Name="first_name" Type="Edm.String" Nullable="false" MaxLength="40" FixedLength="false" Unicode="true"/>
<Property Name="last_name" Type="Edm.String" Nullable="false" MaxLength="40" FixedLength="false" Unicode="true"/>
<Property Name="email" Type="Edm.String" Nullable="false"/>
<Property Name="gender" Type="Edm.String" Nullable="false" MaxLength="40" FixedLength="false"/>
<Property Name="ip_address" Type="Edm.String" Nullable="false" MaxLength="40" FixedLength="false" Unicode="true"/>
</EntityType>
</Schema>
<Schema Namespace="databinding.PersonsData.Model" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityContainer Name="PersonEntities" m:IsDefaultEntityContainer="true" p6:LazyLoadingEnabled="true"
xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
<EntitySet Name="Persons" EntityType="PersonsData.Invoice"/>
</EntityContainer>
</Schema>
</edmx:DataServices>
The SAPUI5 Web IDE says that edmx namespace does not exist.
So I went to check edmx namespace and it does not exists.
Chrome developer tools reports the same error:
Could this be the problem?
I checked and mockserver.init() is triggered.
Did Microsoft moved this namespace somewhere? Cause I was not able to find it.
Thanks

what I see is that you messed up your XML structure. As the error says your XML is invalid.
You've closed the surrounding edmx:Edmx tag at the beginning of the document
You've closed the edmx:DataServices tag too early
Furthermore the attribute name of the property id is in lowercase. Try to make an uppercased Name.
Try to use this xml:
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:DataServices m:DataServiceVersion="1.0" m:MaxDataServiceVersion="3.0"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<Schema Namespace="PersonsData" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityType Name="Person">
<Key>
<PropertyRef Name="id"/>
</Key>
<Property Name="id" Type="Edm.Int16" Nullable="false"/>
<Property Name="first_name" Type="Edm.String" Nullable="false" MaxLength="40" FixedLength="false" Unicode="true"/>
<Property Name="last_name" Type="Edm.String" Nullable="false" MaxLength="40" FixedLength="false" Unicode="true"/>
<Property Name="email" Type="Edm.String" Nullable="false"/>
<Property Name="gender" Type="Edm.String" Nullable="false" MaxLength="40" FixedLength="false"/>
<Property Name="ip_address" Type="Edm.String" Nullable="false" MaxLength="40" FixedLength="false" Unicode="true"/>
</EntityType>
</Schema>
<Schema Namespace="databinding.PersonsData.Model" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityContainer Name="PersonEntities" m:IsDefaultEntityContainer="true" p6:LazyLoadingEnabled="true"
xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
<EntitySet Name="Persons" EntityType="PersonsData.Invoice"/>
</EntityContainer>
</Schema>
</edmx:DataServices>

Related

SAPUI5 - Change the Column Name and Properties from smarttable from oData with no Annotation

I'm developing a SAPUI5 application that's use a smart table component. But the oData provided does not send any annotations in the metatdata file. I'm starting selecting these fields from oData: PriorityName,OrderTypeType,OrderTypeName,Id,DateOpen,HourOpen,BrandName,EquipmentId,EquipmentNumber,SymptomName. But i want to show their as Priority Name, Order Type, Order Type Name, Id, Date Open, Hour Open, Brand Name, Equipment Id, Equipment Number and Symptom Name, respective, in table column header and p13ndialog.
I know that is changed by default in the sap:label property in Property Name tag under EntityType. But according the oData developer, they cant send it to me (He was using JPA and oLingo).
The code above is for my smarttable and the entity used in metadada.
<smartTable:SmartTable entitySet="CustomerOrders" id="tbOrders" tableType="Table" useExportToExcel="true" beforeExport="onBeforeExport"
header="Ordens de Manutenção" showRowCount="true" enableAutoBinding="true" beforeRebindTable="onBeforeRebindTable"
initiallyVisibleFields="PriorityName,OrderTypeType,OrderTypeName,Id,DateOpen,HourOpen,BrandName,EquipmentId,EquipmentNumber,SymptomName"
class="sapUiResponsiveContentPadding">
<smartTable:customToolbar>
<OverflowToolbar design="Transparent">
<ToolbarSpacer/>
<OverflowToolbarButton icon="sap-icon://sort" text="Sort" press="onSort"/>
<OverflowToolbarButton icon="sap-icon://filter" text="Filter" press="onFilter"/>
</OverflowToolbar>
</smartTable:customToolbar>
<table:Table id="innerUi5Table" growing="true" selectionMode="None" visibleRowCountMode="Auto">
<table:rowSettingsTemplate>
<table:RowSettings highlight="{ path: 'PriorityName', formatter: '.formatter.OrderStatusFormatter' }"/>
</table:rowSettingsTemplate>
</table:Table>
</smartTable:SmartTable>
Metadata
<EntityType Name="CustomerOrder">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property Name="BrandName" Type="Edm.String" Nullable="true" MaxLength="150"/>
<Property Name="City" Type="Edm.String" Nullable="true" MaxLength="45"/>
<Property Name="ContactFirstname" Type="Edm.String" Nullable="true" MaxLength="45"/>
<Property Name="ContactLastname" Type="Edm.String" Nullable="true" MaxLength="45"/>
<Property Name="Country" Type="Edm.String" Nullable="true" MaxLength="2"/>
<Property Name="CustomerId" Type="Edm.Int64" Nullable="true"/>
<Property Name="DateOpen" Type="Edm.DateTime" Nullable="true"/>
<Property Name="EquipmentId" Type="Edm.String" Nullable="true" MaxLength="10"/>
<Property Name="EquipmentNumber" Type="Edm.String" Nullable="true" MaxLength="12"/>
<Property Name="EquipmentType" Type="Edm.String" Nullable="true" MaxLength="40"/>
<Property Name="FantasyName" Type="Edm.String" Nullable="true" MaxLength="45"/>
<Property Name="HourOpen" Type="Edm.Time" Nullable="true"/>
<Property Name="Id" Type="Edm.Int64" Nullable="false"/>
<Property Name="Latitude" Type="Edm.String" Nullable="true" MaxLength="12"/>
<Property Name="Longitude" Type="Edm.String" Nullable="true" MaxLength="12"/>
<Property Name="ManufacturerSerialNumber" Type="Edm.String" Nullable="true" MaxLength="255"/>
<Property Name="Material" Type="Edm.String" Nullable="true" MaxLength="8"/>
<Property Name="Neighborhood" Type="Edm.String" Nullable="true" MaxLength="45"/>
<Property Name="Note" Type="Edm.String" Nullable="true" MaxLength="10"/>
<Property Name="Obs" Type="Edm.String" Nullable="true" MaxLength="150"/>
<Property Name="OrderTypeId" Type="Edm.String" Nullable="true" MaxLength="4"/>
<Property Name="OrderTypeName" Type="Edm.String" Nullable="true" MaxLength="45"/>
<Property Name="OrderTypeType" Type="Edm.String" Nullable="true" MaxLength="45"/>
<Property Name="OsImbera" Type="Edm.String" Nullable="true" MaxLength="8"/>
<Property Name="Phone" Type="Edm.String" Nullable="true" MaxLength="11"/>
<Property Name="Plant" Type="Edm.String" Nullable="true" MaxLength="4"/>
<Property Name="PriorityId" Type="Edm.Int32" Nullable="true"/>
<Property Name="PriorityName" Type="Edm.String" Nullable="true" MaxLength="15"/>
<Property Name="State" Type="Edm.String" Nullable="true" MaxLength="2"/>
<Property Name="Status" Type="Edm.String" Nullable="true" MaxLength="1"/>
<Property Name="Street" Type="Edm.String" Nullable="true" MaxLength="150"/>
<Property Name="SymptomId" Type="Edm.Int64" Nullable="true"/>
<Property Name="SymptomName" Type="Edm.String" Nullable="true" MaxLength="45"/>
<Property Name="SymptomObjTecnico" Type="Edm.String" Nullable="true" MaxLength="10"/>
<Property Name="SymptomSAP" Type="Edm.String" Nullable="true" MaxLength="8"/>
<Property Name="TechnicalObjName" Type="Edm.String" Nullable="true" MaxLength="255"/>
<Property Name="WarrantyObs" Type="Edm.String" Nullable="true" MaxLength="45"/>
<Property Name="WorkCenter" Type="Edm.String" Nullable="true" MaxLength="8"/>
<Property Name="Zipcode" Type="Edm.String" Nullable="true" MaxLength="9"/>
</EntityType>
Redefine the rows/columns in your XML manually and bind your labels against i18n model, where you can define all the needed labels.
The bad thing about it - you cannot influence on the columns that potentially could be added via personalisation. Possible workaround - redefine ALL the columns. But in this case once the backend get changed, you have to adjust UI accordingly.

How does odata know which property is the ID?

In the following example russelwhyte is the id, but how does the provider know to map it to the UserName property?
URL: http://services.odata.org/V4/TripPinServiceRW/People?$format=application/json;odata.metadata=full
Response:
{
#odata.context: "http://services.odata.org/V4/(S(ck3fzk3dze0kmzjcruxiz31i))/TripPinServiceRW/$metadata#People",
#odata.nextLink: "http://services.odata.org/V4/TripPinServiceRW/People?%24format=application%2fjson%3bodata.
metadata%3dfull&%24skiptoken=8",
value:
[
{
#odata.type: "#Microsoft.OData.SampleService.Models.TripPin.Person",
#odata.id: "http://services.odata.org/V4/TripPinServiceRW/People('russellwhyte')",
#odata.etag: "W/"08D17DBDFB9CCAAC"",
#odata.editLink: "http://services.odata.org/V4/TripPinServiceRW/People('russellwhyte')",
UserName: "russellwhyte",
FirstName: "Russell",
LastName: "Whyte",
...
Friends#odata.associationLink: "http://services.odata.org/V4/TripPinServiceRW/People('russellwhyte')/Friends/$ref",
Friends#odata.navigationLink: "http://services.odata.org/V4/TripPinServiceRW/People('russellwhyte')/Friends",
...
},
...
]
}
By overriding GetEntityByKey of the base class EntitySetController
Query the metadata document, you can get the model schema for the service, and in which you can find which properties are the keys/IDs.
For example:
GET: http://services.odata.org/V4/(S(ksn5grnrgbebt44osly5z2vr))/TripPinServiceRW/$metadata
<EntityType Name="Person" OpenType="true">
<Key>
<PropertyRef Name="UserName"/>
</Key>
<Property Name="UserName" Type="Edm.String" Nullable="false">
<Annotation Term="Org.OData.Core.V1.Permissions">
<EnumMember>Org.OData.Core.V1.Permission/Read</EnumMember>
</Annotation>
</Property>
<Property Name="FirstName" Type="Edm.String" Nullable="false"/>
<Property Name="LastName" Type="Edm.String" Nullable="false"/>
<Property Name="Emails" Type="Collection(Edm.String)"/>
<Property Name="AddressInfo" Type="Collection(Microsoft.OData.SampleService.Models.TripPin.Location)"/>
<Property Name="Gender" Type="Microsoft.OData.SampleService.Models.TripPin.PersonGender"/>
<Property Name="Concurrency" Type="Edm.Int64" Nullable="false">
<Annotation Term="Org.OData.Core.V1.Computed" Bool="true"/>
</Property>
<NavigationProperty Name="Friends" Type="Collection(Microsoft.OData.SampleService.Models.TripPin.Person)"/>
<NavigationProperty Name="Trips" Type="Collection(Microsoft.OData.SampleService.Models.TripPin.Trip)" ContainsTarget="true"/>
<NavigationProperty Name="Photo" Type="Microsoft.OData.SampleService.Models.TripPin.Photo"/>
</EntityType>

EntityFramework Model First, Composite Primary Key From Foreign Keys

I have a Entity Framework 5 Model First project, with the following tables:
Extension
Id : Int32, PK
Number: String
User
Id: Int32, PK
Name: String
UserExtensionMap
UserId : Int32 (FK -> User.Id), PK
ExtensionId : Int32 (FK -> Extension.Id), PK
When setting the above tables and associations to UserExtensionMap I get the error that UserId and ExtensionId are not mapped.
So I right click on UserExtensionMap table and select table mapping and get the following screen
I can set the maps for Users.Id to UserExtensionUser.Id and Extensions.Id to UserExtension.ExtensionId but there is nothing to map the Extensions.Number and User.Username to - I am confused!
I get with the error when trying to compile:
Error 3024: Problem in mapping fragments starting at line 119:Must specify mapping for all key properties (UserExtensionMaps.ExtensionId, UserExtensionMaps.UserId) of the EntitySet UserExtensionMaps.
When i delete these above maps for UserExtensionMap i get the error:
Error 3027: No mapping specified for the following EntitySet/AssociationSet - UserExtensionMaps.
My model XML file is below:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
<!-- EF Runtime content -->
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="Server.Store" Alias="Self" Provider="System.Data.SqlServerCe.4.0" ProviderManifestToken="4.0" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
<EntityContainer Name="ServerStoreContainer">
<EntitySet Name="Users" EntityType="Server.Store.Users" store:Type="Tables" Schema="dbo" />
<EntitySet Name="Extensions" EntityType="Server.Store.Extensions" store:Type="Tables" Schema="dbo" />
</EntityContainer>
<EntityType Name="Users">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="Username" Type="nvarchar" Nullable="false" />
</EntityType>
<EntityType Name="Extensions">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="Number" Type="nvarchar" Nullable="false" />
</EntityType>
</Schema></edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="Server" Alias="Self" p1:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:p1="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
<EntityContainer Name="ServerEntities" p1:LazyLoadingEnabled="true" >
<EntitySet Name="Users" EntityType="Server.User" />
<EntitySet Name="Extensions" EntityType="Server.Extension" />
<EntitySet Name="UserExtensionMaps" EntityType="Server.UserExtensionMap" />
<AssociationSet Name="ExtensionUserExtensionMap" Association="Server.ExtensionUserExtensionMap">
<End Role="Extension" EntitySet="Extensions" />
<End Role="UserExtensionMap" EntitySet="UserExtensionMaps" />
</AssociationSet>
<AssociationSet Name="UserUserExtensionMap" Association="Server.UserUserExtensionMap">
<End Role="User" EntitySet="Users" />
<End Role="UserExtensionMap" EntitySet="UserExtensionMaps" />
</AssociationSet>
</EntityContainer>
<EntityType Name="User">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Type="Int32" Name="Id" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Type="String" Name="Username" Nullable="false" />
<NavigationProperty Name="UserExtensionMaps" Relationship="Server.UserUserExtensionMap" FromRole="User" ToRole="UserExtensionMap" />
</EntityType>
<EntityType Name="Extension">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Type="Int32" Name="Id" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Type="String" Name="Number" Nullable="false" />
<NavigationProperty Name="UserExtensionMaps" Relationship="Server.ExtensionUserExtensionMap" FromRole="Extension" ToRole="UserExtensionMap" />
</EntityType>
<EntityType Name="UserExtensionMap" >
<Key>
<PropertyRef Name="ExtensionId" />
<PropertyRef Name="UserId" />
</Key>
<NavigationProperty Name="Extension" Relationship="Server.ExtensionUserExtensionMap" FromRole="UserExtensionMap" ToRole="Extension" />
<Property Type="Int32" Name="ExtensionId" Nullable="false" />
<NavigationProperty Name="User" Relationship="Server.UserUserExtensionMap" FromRole="UserExtensionMap" ToRole="User" />
<Property Type="Int32" Name="UserId" Nullable="false" />
</EntityType>
<Association Name="ExtensionUserExtensionMap">
<End Type="Server.Extension" Role="Extension" Multiplicity="1" />
<End Type="Server.UserExtensionMap" Role="UserExtensionMap" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Extension">
<PropertyRef Name="Id" />
</Principal>
<Dependent Role="UserExtensionMap">
<PropertyRef Name="ExtensionId" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="UserUserExtensionMap">
<End Type="Server.User" Role="User" Multiplicity="1" />
<End Type="Server.UserExtensionMap" Role="UserExtensionMap" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="User">
<PropertyRef Name="Id" />
</Principal>
<Dependent Role="UserExtensionMap">
<PropertyRef Name="UserId" />
</Dependent>
</ReferentialConstraint>
</Association>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
<EntityContainerMapping StorageEntityContainer="ServerStoreContainer" CdmEntityContainer="ServerEntities">
<EntitySetMapping Name="Users">
<EntityTypeMapping TypeName="IsTypeOf(Server.User)">
<MappingFragment StoreEntitySet="Users">
<ScalarProperty Name="Id" ColumnName="Id" />
<ScalarProperty Name="Username" ColumnName="Username" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="Extensions">
<EntityTypeMapping TypeName="IsTypeOf(Server.Extension)">
<MappingFragment StoreEntitySet="Extensions">
<ScalarProperty Name="Id" ColumnName="Id" />
<ScalarProperty Name="Number" ColumnName="Number" />
</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/2009/11/edmx">
<Connection>
<DesignerInfoPropertySet>
<DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
</DesignerInfoPropertySet>
</Connection>
<Options>
<DesignerInfoPropertySet>
<DesignerProperty Name="ValidateOnBuild" Value="true" />
<DesignerProperty Name="EnablePluralization" Value="True" />
<DesignerProperty Name="IncludeForeignKeysInModel" Value="True" />
<DesignerProperty Name="CodeGenerationStrategy" Value="None" />
</DesignerInfoPropertySet>
</Options>
<!-- Diagram content (shape and connector positions) -->
<Diagrams></Diagrams>
</Designer>
</edmx:Edmx>
I could not see the table mapping fields until I generated the database code right click model -> Generate Database from model, after doing this the mappings were OK.
Not sure if this is a bug or not, but it is repeatable and does fix the issue.

Issue in EF, mapping fragment,no default value and is not nullable

I am developing MVC 3 Applicaiton.
I have Model first approch.
I have Company Entity(Abstract).
Lead and Customer is inherited from the company entity.
When I tried to validate the model, Its gives an errror.
Error 41 Error 3023: Problem in mapping fragments starting at line
70:Column Companies.Status in table Companies must be mapped: It has
no default value and is not nullable.
Here is the mapping of tables.
And Here is the EDMX code in HTML View.
<?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="Model1.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2008" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator">
<EntityContainer Name="Model1StoreContainer">
<EntitySet Name="Companies" EntityType="Model1.Store.Companies" store:Type="Tables" Schema="dbo" />
</EntityContainer>
<EntityType Name="Companies">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="Name" Type="nvarchar(max)" Nullable="false" />
<Property Name="Status" Type="nvarchar(max)" Nullable="false" />
<Property Name="__Disc__" Type="nvarchar" MaxLength="Max" Nullable="false" />
</EntityType>
</Schema></edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" xmlns:cg="http://schemas.microsoft.com/ado/2006/04/codegeneration" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" Namespace="Model1" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
<EntityContainer Name="Model1Container" annotation:LazyLoadingEnabled="true">
<EntitySet Name="Companies" EntityType="Model1.Company" />
</EntityContainer>
<EntityType Name="Company" Abstract="true">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Type="Int32" Name="Id" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Type="String" Name="Name" Nullable="false" />
</EntityType>
<EntityType Name="Lead" BaseType="Model1.Company" >
<Property Type="String" Name="Status" Nullable="false" />
</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="Model1Container">
<EntitySetMapping Name="Companies">
<EntityTypeMapping TypeName="IsTypeOf(Model1.Company)">
<MappingFragment StoreEntitySet="Companies">
<ScalarProperty Name="Id" ColumnName="Id" />
<ScalarProperty Name="Name" ColumnName="Name" />
<Condition ColumnName="__Disc__" Value="Company" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="Model1.Lead">
<MappingFragment StoreEntitySet="Companies">
<ScalarProperty Name="Id" ColumnName="Id" />
<ScalarProperty Name="Name" ColumnName="Name" />
<ScalarProperty Name="Status" ColumnName="Status" />
<Condition ColumnName="__Disc__" Value="Lead" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
</EntityContainerMapping>
</Mapping></edmx:Mappings>
</edmx:Runtime>
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
<edmx:Designer xmlns="http://schemas.microsoft.com/ado/2008/10/edmx">
<edmx:Connection>
<DesignerInfoPropertySet>
<DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
</DesignerInfoPropertySet>
</edmx:Connection>
<edmx:Options>
<DesignerInfoPropertySet>
<DesignerProperty Name="ValidateOnBuild" Value="true" />
<DesignerProperty Name="EnablePluralization" Value="True" />
<DesignerProperty Name="DatabaseGenerationWorkflow" Value="$(VSEFTools)\DBGen\Generate T-SQL Via T4 (TPH).xaml" />
</DesignerInfoPropertySet>
</edmx:Options>
<!-- Diagram content (shape and connector positions) -->
<edmx:Diagrams>
<Diagram Name="Model1" >
<EntityTypeShape EntityType="Model1.Company" Width="1.5" PointX="2.375" PointY="0.875" Height="1.2636116536458335" />
<EntityTypeShape EntityType="Model1.Lead" Width="1.5" PointX="3.375" PointY="2.625" Height="1.0992643229166665" />
<InheritanceConnector EntityType="Model1.Lead" >
<ConnectorPoint PointX="3.125" PointY="2.1386116536458335" />
<ConnectorPoint PointX="3.125" PointY="2.325" />
<ConnectorPoint PointX="4.125" PointY="2.325" />
<ConnectorPoint PointX="4.125" PointY="2.625" />
</InheritanceConnector>
</Diagram>
</edmx:Diagrams>
</edmx:Designer>
</edmx:Edmx>
Whats is the issue ?
Put the DefaultValue attribute on the SSDL Status property. It would look like this (I used the empty string):
<Property Name="Status" Type="nvarchar(max)" Nullable="false" DefaultValue=""/>
Since the base entity is abstract you won't be able to create entities of this type so this DefaultValue will not really be used but it should make EF stop complaining.
In your storage model, the Companies.Status column doesn't allow null values.
Since all entities that inherit from Company except the Lead entity will not have the Status property set, you need to either allow null in the Companies.Status column or set a default value to use for the other entities.

Entity Framework TPH with multiple abstract inheritance

I'm trying to do a Table Per Hierarchy model in Entity Framework(VS 2008 sp1, 3.5).
Most of my models have been very simple, an abstract type with multiple sub-types that inherit from it.
However, I've been struggling with this latest challenge. I have STUDENTS that I'd like to inherit from PERSONS(abstract) that should inherity from PARTIES(abstract).
Every time I do this I get a "Error 2078: The EntityType 'Model.PERSONS' is Abstract and can be mapped only using IsTypeOf." I guess the problem is PARTIES is already defined as IsTypeOf in the entity set.
So is this even possible? I can work around it by making PERSONS abstract = false and assigning a bogus conditional mapping. But this seems like a silly workaround.
Edit the model using XML Editor: find the mapping and add IsTypeOf to the corresponding EntityTypeMapping tag.
Here is an example resembling your case:
SQL Server DDL:
CREATE TABLE [dbo].[Student] (
[Id] [int] IDENTITY(1,1) NOT NULL,
[PartyInfo] [varchar](max) NOT NULL,
[PersonInfo] [varchar](max) NOT NULL,
[StudInfo] [varchar](max) NOT NULL,
CONSTRAINT [PK_Student] PRIMARY KEY CLUSTERED ( [Id] ASC )
)
EDMX:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="1.0"
xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<!-- EF Runtime content -->
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="test_1Model.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="test_1ModelStoreContainer">
<EntitySet Name="Student" EntityType="test_1Model.Store.Student"
store:Type="Tables" Schema="dbo" />
</EntityContainer>
<EntityType Name="Student">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="int" Nullable="false"
StoreGeneratedPattern="Identity" />
<Property Name="PartyInfo" Type="varchar(max)" Nullable="false" />
<Property Name="PersonInfo" Type="varchar(max)" Nullable="false" />
<Property Name="StudInfo" Type="varchar(max)" Nullable="false" />
</EntityType>
</Schema>
</edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="test_1Model" Alias="Self"
xmlns="http://schemas.microsoft.com/ado/2006/04/edm">
<EntityContainer Name="test_Entities">
<EntitySet Name="PartySet" EntityType="test_1Model.Party" />
</EntityContainer>
<EntityType Name="Party" Abstract="true">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="Int32" Nullable="false" />
<Property Name="PartyInfo" Type="String" Nullable="false"
MaxLength="Max" Unicode="false" FixedLength="false" />
</EntityType>
<EntityType Name="Person" BaseType="test_1Model.Party" Abstract="true" >
<Property Name="PersonInfo" Type="String" Nullable="false" />
</EntityType>
<EntityType Name="Student" BaseType="test_1Model.Person" >
<Property Name="StudInfo" Type="String" Nullable="false" />
</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="test_1ModelStoreContainer"
CdmEntityContainer="test_Entities">
<EntitySetMapping Name="PartySet">
<EntityTypeMapping TypeName="IsTypeOf(test_1Model.Party)">
<MappingFragment StoreEntitySet="Student">
<ScalarProperty Name="PartyInfo" ColumnName="PartyInfo" />
<ScalarProperty Name="Id" ColumnName="Id" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="IsTypeOf(test_1Model.Person)">
<MappingFragment StoreEntitySet="Student">
<ScalarProperty Name="Id" ColumnName="Id" />
<ScalarProperty Name="PersonInfo" ColumnName="PersonInfo" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="test_1Model.Student">
<MappingFragment StoreEntitySet="Student">
<ScalarProperty Name="PartyInfo" ColumnName="PartyInfo" />
<ScalarProperty Name="PersonInfo" ColumnName="PersonInfo" />
<ScalarProperty Name="Id" ColumnName="Id" />
<ScalarProperty Name="StudInfo" ColumnName="StudInfo" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
</edmx:Runtime>
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
<edmx:Designer xmlns="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:Connection>
<DesignerInfoPropertySet>
<DesignerProperty Name="MetadataArtifactProcessing"
Value="EmbedInOutputAssembly" />
</DesignerInfoPropertySet>
</edmx:Connection>
<edmx:Options>
<DesignerInfoPropertySet>
<DesignerProperty Name="ValidateOnBuild" Value="true" />
</DesignerInfoPropertySet>
</edmx:Options>
<!-- Diagram content (shape and connector positions) -->
<edmx:Diagrams>
<Diagram Name="SqlServer_Model" />
</edmx:Diagrams>
</edmx:Designer>
</edmx:Edmx>