I was trying to optimize the performance for my site so i followed these rules
while doing the point about Generating views on compile time i had to create .edmx file, after creating this file and follow all the steps I'm facing this issue:
Schema specified is not valid. Errors:
The property for the relationship 'FK_dbo_X_dbo_Y_x_id' contains a Role 'X' has a type 'Site.Models.X' that is not valid for a relationship End. Change the End Role to an EntityType.
for every relation i have.
can anyone tell me how can i fix this error?
Update :
How i define my relations
in model :
[ForeignKey("foreign_id")]
public EntityCollection<MyClass> relation_obj { get; set; }
in DbContext:
modelBuilder.Entity<X>().HasMany(m => m.relation_obj );
The relation assembly :
[assembly: EdmRelationshipAttribute("DBModel", "FK_dbo_X_dbo_Y_x_id", "X", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(Site.Models.X), "Y", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(Site.Models.Y), true)]
edmxfile so it automatically created new models for every table i have, so i deleted the model and modified the designer and the assembly refs to use the old models like the following :[assembly: EdmRelationshipAttribute("DBModel", "FK_dbo_X_dbo_Y_restaurant_id", "X", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(Site.Models.X), "Y", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(RestaurantApp.Models.Y), true)]and added the pre-build script like they said here:http://msdn.microsoft.com/en-us/library/bb896240.aspx