首页 > 解决方案 > “使用 SQLite;” 变灰

问题描述

我正在做一个多平台的 xamarin 表单项目。我正在为数据库使用 SQLite。我安装了“sqlite-net pcl”nuget。我在主应用程序中创建了一个模型类

using System;
using System.Collections.Generic;
using System.Text;
using SQLite;

namespace MyApp.Models
{
    [Table("vegetables")]
    public class Vegetable
    {
        [PrimaryKey, AutoIncrement]
        public int VegetableId { get; set; }
        [MaxLength (250), Unique]
        public string VegetableName { get; set; }
    }
}

使用 SQLite;是灰色的,Visual Studio 说没有必要包含它。通常,当您键入 [Table("vegetables")] 时,“Table”会变为蓝色,表示它是 TableAttribute。在我的代码表中,PrimaryKey 等保持黑色,似乎没有任何关联。

我正在关注我从教科书中所做的示例项目,它在示例中工作,我对我的代码执行相同的步骤,但遇到了这个问题。我错过了什么?

标签: c#visual-studiosqlitexamarin.forms

解决方案


推荐阅读