Beg*_*ner 5 .net c# entity-framework compiler-errors
我正在一步一步地学习mvc和创建一个音乐商店,但由于某种原因,我无法得到以下代码工作..
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
namespace MvcMusicStore.Models
{
public class MusicStoreEntities : DbContext
{
public DbSet<Album> Albums { get; set; }
public DbSet<Genre> Genres { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
DBcontext,DbSet和DbSet给出错误......
错误1找不到类型或命名空间名称'DbContext'(您是否缺少using指令或程序集引用?)
为什么?
您必须将EntityFramework.dll
程序集的引用添加到项目中.最简单的方法是安装相应的NuGet包.如果已安装ASP.NET MVC 3工具更新,则在创建新项目时,默认情况下会引用此NuGet包.如果没有,只需安装即可.
归档时间: |
|
查看次数: |
6832 次 |
最近记录: |