Reputation: 1523
I'm trying to write my first app in Entity Framework.
In program.cs
(where my main()
is) I have line ProdContext ctx = new ProdContext();
. The prodContext.cs
is:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data.Entity;
using System.Text;
namespace Entity_Framework
{
class ProdContext : DbContext
{
public DbSet<Category> Categories { get; set; }
public DbSet<Product> Products { get; set; }
}
}
While trying to run main I get exception at above line:
FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
I have fresh install of Visual Studio with C# and EF (I installed it with install-package entityframework -version 6.1.3.0
). Why am I getting that exception?
Upvotes: 1
Views: 181
Reputation: 1600
I would suggest that you're using .NET Core application while still trying to install .NET library. EF 6 is ".NET" specific library. With .NET Core application type for your project you will have such crash (or similar) if installing .NET EF Version:
For .NET Core applications, you should install Core version. https://www.nuget.org/packages/Microsoft.EntityFrameworkCore/
Make sure you don't have this (or similar) error in your references:
Upvotes: 2