I have generated my models from my database. One of the models looks like:
namespace LV.Models
{
using System;
using System.Collections.Generic;
public partial class Ac
{
public int IdAc { get; set; }
public int IdEmp { get; set; }
public Nullable<System.DateTime> dtd{ get; set; }
public Nullable<int> Sn{ get; set; }
public Nullable<bool> A{ get; set; }
public Nullable<int> IdSi{ get; set; }
public Nullable<bool> Gest{ get; set; }
public Nullable<int> IdResp { get; set; }
public string SigXML { get; set; }
public Nullable<bool> Read { get; set; }
public Nullable<System.DateTime> EndDate{ get; set; }
public string dpd{ get; set; }
public string gda { get; set; }
public string typeaq { get; set; }
public byte[] attch { get; set; }
public string exten { get; set; }
public virtual AC emps { get; set; }
}
}
When I try to create a Controller, it says that has no key defined
. I tried the solution from other posts where says that I have to use [Key]
and it creates my Controller but when I run the project it throws me another exception that says the following table cannot be created
. It says that because the table already exist.
I use Visual Studio 2013 Express with EF 6 <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
The primary key is idAc
. It is also Identity. If I check the diagram, that's what it says.
From what I've seen, the mapping is good. All my keys, relations, primary keys, identity fields where identified in the diagram.