2

I have For Example Product and a ProductDetail Table. Where in Model Product is a base class for ProductDetail. There is a ProductName in ProductDetail. Everything is working fine but I wanted to know that why the EF is giving me this warning and how to remove this. I tried updating Designer.cs with a new keyword was just keen to see what happens but it removes it as soon as it is compiled.

Googled it out but did not find any relevant information. So m here asking a question if anybody knows how to deal with this warning.

The Warning which I get is here:

  DataLayer.ProductDetail.ProductName' hides inherited member
 'Product.ProductName'. Use the new keyword if hiding was intended.     
Henk Holterman
  • 250,905
  • 30
  • 306
  • 490
Nivid Dholakia
  • 5,008
  • 4
  • 28
  • 55

1 Answers1

0

This is generic C# warning. If you have a base class that has a member with the same name as one in the child class, you will get this warning. It is basically telling you to be careful, as ProductName might not refer to what you expect.

In this particular case, if you set ProductName on ProductDetail, then the ProductName on the Product class will not be set. Depending on your mapping, this may or may not be an issue.

Erick

Erick T
  • 6,611
  • 7
  • 43
  • 81
  • I know but its an auto generated EF model that is why i am asking. I tried it with new that overrides but some how EF designer removes that on compiling. – Nivid Dholakia Nov 01 '11 at 22:16
  • It did some how work today. Yesterday dont know it delted my new keyword. I knew it but still you get the credit. Thanks for the Reply. – Nivid Dholakia Nov 02 '11 at 20:49