Sto tentando di creare una colonna "time (7)" in una tabella con Entity Framework Code First. Questo è il mio Entità:SQL "time" digitare in Entity Framework Code First
public class ShiftDetail
{
public long Id { get; set; }
[Required]
public int DayOfWeek { get; set; }
[Required]
[Column(TypeName="time")]
public DateTime StartTime { get; set; }
[Required]
[Column(TypeName = "time")]
public DateTime EndTime { get; set; }
public long ShiftId { get; set; }
public virtual Shift Shift { get; set; }
}
Come potete vedere sto cercando di impostare il tipo di database per le colonne StartTime e EndTime a "tempo" ma ottengo questo errore:
(112,12) : error 2019: Member Mapping specified is not valid. The type 'Edm.DateTime[Nullable=False,DefaultValue=,Precision=]' of member 'StartTime' in type 'ShiftDetail' is not compatible with 'SqlServer.time[Nullable=False,DefaultValue=,Precision=7]' of member 'StartTime' in type 'CodeFirstDatabaseSchema.ShiftDetail'.
I' ve provato anche con TypeName = "tempo (7)", ma ottengo questo altro errore:
(104,6) : error 0040: The Type time(7) is not qualified with a namespace or alias. Only primitive types can be used without qualification.
Come si crea una colonna tempo con il codice di prima? (preferibilmente senza API fluente)
Grazie in anticipo.
Se si utilizza il progettista EDMX, quale tipo di dati sceglie per la colonna temporale? Probabilmente non dovresti usare 'DateTime', ma non sono sicuro di quale sia il tipo giusto, e questo è un modo semplice per scoprirlo. – hvd