在CLI上,我使用 dotnet dbcontext列表查看EF是否可以看到我的dbcontext( TestCoreASP.Data.TestCoreDbContext )。之后,我尝试使用 dotnet ef dbcontext info
从此DbContext查看信息。然后我收到以下错误消息。但是,在我的代码的任何地方都没有创建一个名为FilterDescriptor的实体-这是什么?
EF CLI版本2.1.4
ASP.NET Core 2.1
找不到适用于实体类型'FilterDescriptor'的合适构造函数。以下参数无法绑定到实体的属性:“ filter”,“ FilterScope”
public class TestCoreDbContext : DbContext
{
public TestCoreDbContext(DbContextOptions options)
: base (options)
{
}
public DbSet<Restaurantcs> Restaurants { get; set; }
}
public class SqlRestaurantData : IResturantData
{
private TestCoreDbContext _context;
public SqlRestaurantData(TestCoreDbContext context)
{
_context = context;
}
public Restaurantcs Add(Restaurantcs newRest)
{
_context.Restaurants.Add(newRest);
_context.SaveChanges();
return newRest;
}
public IEnumerable<Restaurantcs> GetAll()
{
return _context.Restaurants.OrderBy(r => r.Name);
}
public Restaurantcs GetSingle(int id)
{
return _context.Restaurants.FirstOrDefault(r => r.Id == id);
}
}
public class Restaurantcs : Controller
{
public int Id { get; set; }
[Display(Name="Resturant Name")]
[Required, MaxLength(80)]
public string Name { get; set; }
public CuisineType Cuisine { get; set; }
}
private IConfiguration _configuration;
public Startup(IConfiguration configuration)
{
_configuration = configuration;
}
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IGreeter, Greeter>();
services.AddDbContext<TestCoreDbContext>(
options => options.UseSqlServer(_configuration.GetConnectionString("TestCoreASP")));
services.AddScoped<IResturantData, SqlRestaurantData>();
services.AddMvc();
}