0

I have created a class library which is used to implement the logic of my project but when I try to run my code this error is shown :

Could not load file or assembly EntityFramework ...

I think this error is meaningless because the EF6 has been installed on my Visual Studio 2013.

Inside the app.config I have defined a connection string:

<connectionStrings>
    <add name="con0"
         connectionString="Persist Security Info=False;Integrated Security=true;Initial Catalog=jasmin;server=(local)"
         providerName="System.Data.sqlclient" />
</connectionStrings> 

This is my context class:

public class SchoolClassContext : DbContext
{
    public SchoolClassContext() : base("name=con0") { }
    public DbSet<SchoolClass> SchoolClassCtx;
    public DbSet<Teacher> TeacherCtx;
    public DbSet<List<Student>> StudentsCtx;
}

This is my method:

public virtual TransActionInfo AddClass()
{
    transActionInfo = new TransActionInfo();        
    classContext = new SchoolClassContext();          

    var schoolclass = new SchoolClass() {
                ClassID = base.ClassID,
                Title = base.Title,
                Location = base.Location,
                Schedule = base.Schedule,
                State = base.State,
                TTeacher = base.TTeacher,
                Students = base.Students                
         };

    try
    {
        classContext.SchoolClassCtx.Add(schoolclass);
        classContext.SaveChanges();

        transActionInfo.Status = TransactionStatus.Status.Successful;
        transActionInfo.ObjectName = base.GetType().Name;
        transActionInfo.ObjectLastState = schoolclass;
        transActionInfo.TransactionTime = DateTime.Now;

        return transActionInfo;
    }
    catch(Exception e)
    {
        transActionInfo.Status = TransactionStatus.Status.Abort;
        transActionInfo.Msg = e.ToString();
        transActionInfo.TransactionTime = DateTime.Now;

        return transActionInfo;
    }           
}

Any suggestion ?

2 Answers 2

1

After installing EntityFramework with NuGet-Packagemanager, you should make sure that you have EntityFramework in your references list:

VS References

After building your solution you should have a EntityFramework.dll in your debug folder side by side with your own executable:

VS Debug Folder

Hope it helps

Sign up to request clarification or add additional context in comments.

Comments

0

Try to install EF in your project with nuget package manager console.

https://www.nuget.org/packages/EntityFramework

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.