I have a MVC4 internet application, whose Model is using a partial class as well as a partial method. the code is as follows:
namespace ePhoneBookMvc4Application.Models
{
public partial class PhoneBook : ePhoneBookMvc4Application.Repositories.PhoneBook
{
public bool IsValid
{
get { return (GetRuleViolations().Count() == 0); }
}
public IEnumerable<RuleViolation> GetRuleViolations()
{
if (String.IsNullOrEmpty(FirstName))
{
yield return new RuleViolation("First Name Required", "FirstName");
}
if (!OnValidatePropertyForPhonebook.CharStringValidator(FirstName))
{
yield return new RuleViolation("Please Enter Valid First Name", "FirstName");
}
yield break;
}
partial void OnValidate(System.Data.Linq.ChangeAction action)
{
if(!IsValid)
{
throw new ApplicationException("Rule violations prevent saving");
}
}
}
}
but during Build, i am getting an error as follows:
No defining declaration found for implementing declaration of partial method ePhoneBookMvc4Application.Models.PhoneBook.OnValidate(System.Data.Linq.ChangeAction)
whereas the partial method is defined in the
.designer.cs file in the
Repositories. Is it necessary that the
Repository.cs,IRepository and the
Phonebook.dbml files must be in the same folder as the
Model.Phonebook ?
Please help.