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

  • SEARCH
  • Home
  • 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 6576359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:30:08+00:00 2026-05-25T15:30:08+00:00

I am learning Microsofts built in Unit Testing capability in VS2010 and came across

  • 0

I am learning Microsofts built in Unit Testing capability in VS2010 and came across a problem.

[TestClass]
public class HomeControllerTest
{

    [TestMethod]
    public void SomeTest()
    {
        //Arrange
        HomeController controller = new HomeController();


        //Act
        ViewResult results = controller.Index() as ViewResult;

        //Assert
        ViewDataDictionary viewData = results.ViewData;

        Assert.AreEqual(null, viewData["Message"]);

    }
}

I know this will return failed, that isn’t an issue. What is an issue however is that I am hitting my EntityFramework model “myModel.edmx” and getting the error "System.ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid."

This is in the file MyModel.Designer.cs. The line in question is:

public Tool_Entities() : base("name=Tool_Entities", "Tool_Entities")
{
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}

I know this line is ok as when I run the non-test project, I can connect to this model fine.

  • 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-05-25T15:30:09+00:00Added an answer on May 25, 2026 at 3:30 pm

    You should abstract out EF from your controllers in a service-oriented or repository way. That way you can remove the dependency (and inject a mock) for your unit tests and just test your controllers.

    First create an interface. This is just a blueprint, you can make it what ever way you want.

    public interface IToolRepository
    {
       void Add(Tool something);
       IQueryable<Tool> Query { get; }
       void Delete(Tool something);
    }
    

    Then implement this with EF.

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

Sidebar

Related Questions

I am just learning Blend/Silverlight/VS2010/.net/etc. I have a simple project that resides on a
I'm using VS2010 together with C# and XNA 4.0. I'm following the book Learning
Please help! I'm still learning so this might be completely wrong. I have built
Should I invest time learning Microsoft's new F# language? I am mainly a C#
Just I started learning MVC pattern, of course i am learning it from Microsoft's
I am learning MVVM using sample created by Josh Smith at http://msdn.microsoft.com/en-us/magazine/dd419663.aspx I wanted
Are there any 100% Microsoft developers out there who have ventured out into learning
Where can I start learning Windows Form designing? For example: Microsoft Zune player, Buttons,
Learning WPF nowadays. Found something new today with .Net dependency properties. What they bring
Learning a little about T-SQL, and thought an interesting exercise would be to generate

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.