我正在使用ASP.NET Core MVC,但是我正在使用的教程是ASP.NET MVC 3(这是我遇到的最好的特定教程)。当我被要求使用代码优先方法将SQL Server连接到我的项目时,我遇到了障碍。
我已经更改了web.config
文件,并创建了一个新类来表示实体框架。尝试执行此操作后,我只是遇到了错误(尤其是using System.Data.Entity;
未被识别,DbContext
和DbSet
都不被识别)。
我相信本教程所推荐的内容已过时,我尝试研究一种最新的解决方案,但找不到任何东西。也可能是我添加到配置文件中的<connectionStrings>
部分有问题,但是我也找不到任何内容。
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; }
}
}
作为参考,该教程页面: