Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
I have been doing most of my coding in is Visual Studio 2015, but my current project requires Visual Studio 2010 for compatibility with the rest of the team. In VS 2015 if I need to use Entity I would just add the NuGet package EntityFramework. In VS 2010 I installed the EntityFramework NuGet Package, so why did I still had to manualy add the assembly reference to System.Data.Entity.dll. in order to use DbContext and Dbset.

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Data.Entity;

namespace ProbateCT.Models
{
    
    public class ValuesModels : DbContext
    {
        public DbSet<Ticket> tickets { get; set; }
    }
    public class Ticket
    {
        public int id { get; set; }
        public bool Urgent { get; set; }
        public bool Open { get; set; }
        public string CallersName { get; set; }
        public string CallBackNumber { get; set; }
        public string Issue { get; set; }
        public string Solution { get; set; }
        public string LicenseNumber { get; set; }
        public string Type { get; set; }
        public string Department { get; set; }
        public string Error { get; set; }
        public Ticket()
        {

        }
    }
Posted
Updated 23-Dec-15 8:21am
v2
Comments
Sergey Alexandrovich Kryukov 23-Dec-15 11:40am    
The question, as formulated, makes no sense. What is your problem?
Now, unrelated issue: look at the name of your class; it contains "Class" in it. No kidding?
—SA
ryanba29 23-Dec-15 14:23pm    
Updated question and removed the class named class, I think that was a copy and past misstake

1 solution

You always need to add a reference to the assembly you want to use. If you install some .NET library, it means that it is added to the GAC. But how the build would know what library to reference in an assembly which needs to use one or more other assemblies. Probably, the question is based on some misconception related to .NET and assemblies. As this is one of the fundamentals, you have to learn about assemblies and their role:
Understanding and Using Assemblies and Namespaces in .NET[^],
Global Assembly Cache[^],
Assembly (CLI) - Wikipedia, the free encyclopedia[^],
Global Assembly Cache - Wikipedia, the free encyclopedia[^].

—SA
 
Share this answer
 
Comments
ryanba29 23-Dec-15 15:56pm    
I have no doubt that I more than one misconception related to assemblies, and looks like I have a lot of reading to do to see if this answers my question, but I'm assuming it will. Then why when doing that same thing in 2015 did installing the NuGet package remove the need to manually add the reference?
Sergey Alexandrovich Kryukov 23-Dec-15 16:22pm    
Frankly, I don't know when and how "remove the need to manually add the reference" ever happened. Maybe, your observations are not accurate. Can you remember exactly, on what action the assembly reference appeared in the project? Maybe you don't remember how exactly it happened?

I can only explain possible rationale behind adding references to a project. Too different things could be referred as to as "NuGet": package manager and its support for VS in the form of VS add-on. It provides a way to install packages, managed them, whatever.

But why it can possibly affect creation of the project? In one project, you indent to use System.Data.Entity. In another project, you really only need System. Why would any reference be added "automatically"? Just think about it. It would be intrusive, create fake dependencies, and so on. Many people create projects from template and never remove references added to the project by template. I think even that is bad.

What happens when you create a brand new project is controlled by a project template. It's quite a reasonable practice to create your own template, because only you know what would be the most convenient starting point of the project created initially. Please read about it: https://msdn.microsoft.com/library/s365byhx%28v=vs.100%29.aspx.

—SA
ryanba29 23-Dec-15 16:35pm    
I think the problems is that I'm having trouble expressing the exact set a events that's puzzling me. Let me run through the same steps in both version of VS to make sure my observations are correct, and I'll either reword the question or point out my mistake. It's going to be tomorrow before I'll have a chance to re post.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900