3

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.     
H H
  • 263,252
  • 30
  • 330
  • 514
Nivid Dholakia
  • 5,272
  • 4
  • 30
  • 55
  • Are you sure you don't have 2 properties (columns) ProductName? How did you setup the inheritance? – H H Nov 01 '11 at 22:11
  • I have just imported the table basically both have a primary key as productId but in the ProductDetail its a foreign key. – Nivid Dholakia Nov 01 '11 at 22:15
  • And do both tables have a ProductName column? (They shouldn't). – H H Nov 01 '11 at 22:16
  • No Product does not have ProductName – Nivid Dholakia Nov 01 '11 at 22:17
  • Re-check your mappings et,. this shouldn't be happening. The error indicates taht there is a 'Product.ProductName' property. – H H Nov 01 '11 at 22:23
  • I checked it and it is because its partial class and access is public if we make it internal warning is gone but gets me different erros... We need it public because you may know we need it for objects around the applications. – Nivid Dholakia Nov 01 '11 at 22:32
  • Product is a Base AbstractClass – Nivid Dholakia Nov 01 '11 at 22:36
  • `partial` is not the problem and not the solution. But I don't get the `abstract class Product`. Is it based on a table or not? – H H Nov 01 '11 at 22:55
  • Yes its table but i have several other entities linked to it and made a datalayer also partial class so product is abstract because other classes implement the methods defined in that. – Nivid Dholakia Nov 02 '11 at 00:59

1 Answers1

1

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
  • 7,009
  • 9
  • 50
  • 85
  • 1
    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