Entity Framework hides inherited member Warning

被刻印的时光 ゝ 提交于 2019-12-12 21:24:42

问题


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.     

回答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



来源:https://stackoverflow.com/questions/7973478/entity-framework-hides-inherited-member-warning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!