错误EntityType没有定义键。甚至在添加Key Annotation之后

时间:2015-08-05 17:12:25

标签: c# asp.net-mvc entity-framework-6 sql-server-ce

我收到了一个错误:

  

EntityType“Person”没有定义键。定义此EntityType的密钥。

即使添加了spin.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { /*Intent intent = new Intent(getApplicationContext(),SousMenu.class); startActivity(intent);*/ try { JSONObject MenuClicked = jsonArray.getJSONObject(position); Intent showDetails = new Intent(getApplicationContext(), Comm.class); showDetails.putExtra("N_TABLE", MenuClicked.getInt("N_TABLE")); startActivity(showDetails); } catch (JSONException e) { e.printStackTrace(); } } }); 注释。

我已经安装了[Key]版本6.1.3

的软件包

此错误是与SQL Server Compact Edition有关还是我缺少其他配置?

以下是EntityFramework.SQLServerCompact

的班级定义
Person

上下文定义:

public class Person
{
    [Key]
    public int Id;

    [EmailAddress]
    [Required(ErrorMessage = "Please enter the appropriate Email Address")]
    public string Email;

    [Display(Name = "Full Name")]
    [Required(ErrorMessage = "Please enter your full name")]
    public string FullName;

    [Display(Name = "Company Name")]
    [Required(ErrorMessage = "Please enter your company name")]
    public string CompanyName;

    public string Password;

    public bool IsAdmin = false;
}

public class WorkLogContext : DbContext { public DbSet<Person> Persons { get; set; } } 中的连接字符串:

web.config

0 个答案:

没有答案