I am creating an application from this link. Following is my DatabaseInitializer.cs
class:
private static List<Product> GetProducts()
{
var products = new List<Product>{
new Product
{
ProductID = 1,
ProductName="HTC",
ProductDescription="HTC Mobiles are very nice",
ImagePath="htc.jpg",
UnitPrice=25000,
CategoryID=1
},
new Product
{
ProductID = 2,
ProductName="Nokia",
ProductDescription="Mokia Lumia Mobiles are very smart",
ImagePath="nokia.jpg",
UnitPrice=30000,
CategoryID=1
},
new Product
{
ProductID = 3,
ProductName="Samsung",
ProductDescription="Samdung Mobiles are very great",
ImagePath="samsung.jpg",
UnitPrice=20000,
CategoryID=1
},
new Product
{
ProductID = 4,
ProductName="Apple",
ProductDescription="Apple Laptops are very superb",
ImagePath="apple.jpg",
UnitPrice=80000,
CategoryID=2
},
new Product
{
ProductID = 5,
ProductName="Dell",
ProductDescription="Dell Laptops are very nice",
ImagePath="dell.jpg",
UnitPrice=45000,
CategoryID=2
},
new Product
{
ProductID = 6,
ProductName="Lenovo",
ProductDescription="Lenovo Laptops are very great",
ImagePath="lenovo.jpg",
UnitPrice=50000,
CategoryID=2
},
new Product
{
ProductID = 7,
ProductName="Cannon",
ProductDescription="Cannon Cameras are very nice",
ImagePath="cannon.jpg",
UnitPrice=25000,
CategoryID=3
},
new Product
{
ProductID = 8,
ProductName="Nikon",
ProductDescription="Nikon Cameras are superb",
ImagePath="nikon.jpg",
UnitPrice=35000,
CategoryID=3
},
new Product
{
ProductID = 9,
ProductName="Sony",
ProductDescription="Sony Cameras are very great",
ImagePath="sony.jpg",
UnitPrice=40000,
CategoryID=3
},
new Product
{
ProductID = 10,
ProductName="Creative",
ProductDescription="Creative Speakers are very nice",
ImagePath="creative.jpg",
UnitPrice=25000,
CategoryID=4
},
new Product
{
ProductID = 11,
ProductName="Jbl",
ProductDescription="Jbl Speakers are great",
ImagePath="jbl.jpg",
UnitPrice=45000,
CategoryID=4
},
new Product
{
ProductID = 12,
ProductName="Philips",
ProductDescription="Philips Speakers are awesome",
ImagePath="philips.jpg",
UnitPrice=35000,
CategoryID=4
},
};
return products;
}
now i have to change the image entry. I have to insert the png images. For that I have enable the migration for the dbcontext class. Then in the Configuration.cs class i have inserted the following code:
protected override void Seed(SamplePayPalApp.Models.ProductDbContext context)
{
var New_Products = new List<Product>
{
new Product{ImagePath="htc.png"},
new Product{ImagePath="nokia.png"},
new Product{ImagePath="samsung.png"},
new Product{ImagePath="apple.png"},
new Product{ImagePath="dell.png"},
new Product{ImagePath="lenovo.png"},
new Product{ImagePath="cannon.png"},
new Product{ImagePath="nikon.png"},
new Product{ImagePath="sony.png"},
new Product{ImagePath="creative.png"},
new Product{ImagePath="jbl.png"},
new Product{ImagePath="philips.png"},
};
New_Products.ForEach(np => context.Products.AddOrUpdate(p => p.ImagePath, np));
context.SaveChanges();
}
Now, When i am running the Update-Database
command in the Package Manager Console
i am getting the following error: