Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8115361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:27:27+00:00 2026-06-06T03:27:27+00:00

I am creating an asp.net mvc 3 app in Visual Studio 2010. Im trying

  • 0

I am creating an asp.net mvc 3 app in Visual Studio 2010. Im trying to use FluentValidation for my Models. I installed the packages (FluentValidation, FluentValidationMVC3) using NuGet. My Models are as follows (simplified for this forum):

public class ActivityLine : AbstractValidator<ActivityLine>
{
    [Key]
    [Required]
    public int ActivityLineId { get; set; }

    public virtual ICollection<TimeModel> TimeModels { get; set; }
}

public class ActivityLineValidator : AbstractValidator<ActivityLine>
{
    public ActivityLineValidator()
    {
        RuleFor(x => x.TimeModels).SetCollectionValidator(new TimeModelValidator());
    }
}


[Validator(typeof(TimeModelValidator))]
public class TimeModel
{
    [Key]
    public int TimeModelId { get; set; }
    [Required]
    public int ActivityLineId { get; set; }
    [Required]
    public int LineNumber { get; set; }
    public int startHours { get; set; }
    public int startMinutes { get; set; }
    public int endHours { get; set; }
    public int endMinutes { get; set; }

    public virtual ActivityLine ActivityLine { get; set; }

    [NotMapped]
    public TimeSpan StartTime
    {
        get { return new TimeSpan(startHours, startMinutes, 0); }
        set { startHours = value.Hours; startMinutes = value.Minutes; }
    }
    [NotMapped]
    public TimeSpan EndTime 
    {
        get { return new TimeSpan(endHours, endMinutes, 0); }
        set { endHours = value.Hours; endMinutes = value.Minutes; } 
    }
}

public class TimeModelValidator : AbstractValidator<TimeModel>
{
    public TimeModelValidator()
    {
        RuleFor(timemodel => timemodel.endHours)
           .GreaterThan(timemodel => timemodel.startHours)
           .WithMessage("Start Time Must be before End Time");
    }
}

In my Controller :

[HttpPost]
public ActionResult Create(ActivityLine model)
{
    if (ModelState.IsValid)
    {
        personnel.ActivityLines.Add(model);
        personnel.SaveChanges();
        return RedirectToAction("Index");
    }
    //Model State Not Valid Redisplay Form
    return View(model);
}

ModelState is always true even when I assign invalid values to and instance of TimeModel. The project then bombs when it hits the personnel.SaveChagnes() line. I get a “No Source Available” error. The detail is below:

Locating source for 'c:\Projects\FluentValidation\src\FluentValidation\Attributes\ValidatorAttribute.cs'. Checksum: MD5 {e3 d4 90 62 70 f7 a6 4e 9e ac 62 71 77 21 64 dd}

The file ‘c:\Projects\FluentValidation\src\FluentValidation\Attributes\ValidatorAttribute.cs’ does not exist.
Looking in script documents for ‘c:\Projects\FluentValidation\src\FluentValidation\Attributes\ValidatorAttribute.cs’…
Looking in the projects for ‘c:\Projects\FluentValidation\src\FluentValidation\Attributes\ValidatorAttribute.cs’.
The file was not found in a project.
Looking in directory ‘C:\Program Files\Microsoft Visual Studio 10.0\VC\crt\src\’…
Looking in directory ‘C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\src\mfc\’…
Looking in directory ‘C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\src\atl\’…
Looking in directory ‘C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include\’…
The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: c:\Projects\FluentValidation\src\FluentValidation\Attributes\ValidatorAttribute.cs.
The debugger could not locate the source file ‘c:\Projects\FluentValidation\src\FluentValidation\Attributes\ValidatorAttribute.cs’.

I assume something is wrong with my configuration, but I cannot figure out what. Has anyone using Fluent had this issue? What do I need to do to resolve it? My project is located on a network share if that makes a difference.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T03:27:28+00:00Added an answer on June 6, 2026 at 3:27 am

    Your ActivityLine domain model should not derive from AbstractValidator. It should be decorated with the Validator attribute as you did with your TimeModel:

    [Validator(typeof(ActivityLineValidator))]
    public class ActivityLine
    {
        [Key]
        [Required]
        public int ActivityLineId { get; set; }
    
        public virtual ICollection<TimeModel> TimeModels { get; set; }
    }
    
    public class ActivityLineValidator : AbstractValidator<ActivityLine>
    {
        public ActivityLineValidator()
        {
            RuleFor(x => x.TimeModels).SetCollectionValidator(new TimeModelValidator());
        }
    }
    

    Also make sure you have the following line in your Application_Start to enable the FluentValidation metadata provider as explained in the documentation:

    FluentValidationModelValidatorProvider.Configure();
    

    As far as the bombing on the personnel.SaveChagnes() line is concerned, this has strictly nothing to do neither with ASP.NET MVC nor with FluentValidation.NET. I guess it’s the data access technology that you are using that you are having problems with.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating an asp.net MVC app, first time I've done this. I have a
I'm creating a multi-tenant Asp.Net MVC 3 Web app, and using EF4.1 code first
I'm new to ASP.NET MVC and I'm creating an app that will search a
I'm creating a small app in ASP.NET MVC that generates ics (iCal) files based
I am creating a small app to teach myself ASP.NET MVC and JQuery, and
I'm creating an ASP.NET MVC app that uses EF to perform all DB tasks.
I am creating an ASP.NET MVC application that has postcode lookup functionality. I capture
I'm creating a ASP.NET MVC website and I was wandering which techniques do you
I am creating an ASP.Net MVC website that I am launching soon in private
We're creating an ASP.Net MVC site that will need to store 1 million+ pictures,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.