user4515101
user4515101

Reputation: 107

EF Give following Id insted of my number

I Get Table with Products from 1 to 10 Insted 1-4 and 7 to 12

db.product.Add(new Product() {Id=1 ,ProductType = 0,Active = false,});
db.product.Add(new Product() { Id = 2, ProductType = 0, Active = false, });
db.product.Add(new Product() { Id = 3, ProductType = 0, Active = false, });
db.product.Add(new Product() { Id = 4, ProductType = 0, Active = false, });
//  db.product.Add(new Product() { Id = 5, ProductType = 1, Active = false,SensorValue = 0});
//   db.product.Add(new Product() { Id = 6, ProductType = 2, Active = false, SensorValue = 0 });
db.product.Add(new Product() { Id = 7, ProductType = 3, Active = false, SensorValue = 0 });
db.product.Add(new Product() { Id = 8, ProductType = 4, Active = false, SensorValue = 0 });
db.product.Add(new Product() { Id = 9, ProductType = 5, Active = false, SensorValue = 0 });
db.product.Add(new Product() { Id = 10, ProductType = 6, Active = false});
db.product.Add(new Product() { Id = 11, ProductType = 7, Active = false });
db.product.Add(new Product() { Id = 12, ProductType = 8, Active = false });

Upvotes: 1

Views: 34

Answers (1)

user4515101
user4515101

Reputation: 107

[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]

public int Id { get; set; }

Upvotes: 1

Related Questions