Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
When I try to insert a record using Entity frame work to SQL Database i got below error


System.Data.Entity.ModelConfiguration.ModelValidationException: One or more validation errors were detected during model generation:

DAL.EntityFramework.DataTable: : EntityType 'DataTable' has no key defined. Define the key for this EntityType.
DAL.EntityFramework.CultureInfo: : EntityType 'CultureInfo' has no key defined. Define the key for this EntityType.
DAL.EntityFramework.DateTimeFormatInfo: : EntityType 'DateTimeFormatInfo' has no key defined. Define the key for this EntityType.
DataTables: EntityType: EntitySet 'DataTables' is based on type 'DataTable' that has no keys defined.
CultureInfoes: EntityType: EntitySet 'CultureInfoes' is based on type 'CultureInfo' that has no keys defined.
DateTimeFormatInfoes: EntityType: EntitySet 'DateTimeFormatInfoes' is based on type 'DateTimeFormatInfo' that has no keys defined.

What I have tried:

[Table("InventoryE")]
   public class InventoryE
   {

       [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
       [Key]
       public int ID { get; set; }
       public string ITEM_SID { get; set; }
       public int SBS_NO { get; set; }
       public string ALU { get; set; }
       public string STYLE_SID { get; set; }

   }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900