(Playing around with the MVC framework) I have created a ADO.net Entity Data Model. Now I'd like to extend it with some business logic, like creating functions returning subsets of the context. A partial class is created together with the Data Model, so I created a new file declaring a partial class like this:
I placed a function in it called GetMovieById(int id) and the result looks like this:
namespace RecordStore.Models
{
public partial class MovieDBEntities
{
public Movie GetMovieById(int id)
{
Movie movie = MovieSet.First(m => m.id == id);
return movie;
}
}
}
I get no errors until I start the project, and then the error is:
Compiler Error Message: CS1061: 'RecordStore.Models.MovieDBEntities' does not contain a definition for 'MovieSet' and no extension method 'MovieSet' accepting a first argument of type 'RecordStore.Models.MovieDBEntities' could be found (are you missing a using directive or an assembly reference?)
I don't understand the error because the other part of the partial class contains the MovieSet. My question is basically, if this is not the way to extend the Data Model, what would be the way, and in case it is the way, why am I getting this error?