开发者

Entity Framework cannot access entity classes

开发者 https://www.devze.com 2023-04-07 14:06 出处:网络
I have used Entity Framework for DAL in a few projects but in the one I\'m working on right now, I have the edmx file in a class library project and that\'s all there is in the project. I have this pr

I have used Entity Framework for DAL in a few projects but in the one I'm working on right now, I have the edmx file in a class library project and that's all there is in the project. I have this project referenced in another class library project and for some reason I'm not able to access any of the entity classes that are defined in the .designer.cs file. I can't access the context class either. If i look at the referenced project in Object viewer in visual studio, it does not list any entities for this project.

D开发者_如何学Pythonoes anyone know why I'm not able to access the entity classes or the datacontext in another project?

EDIT: If it makes any difference, it's associated with a database on sql azure.


This is can happen into two different ways. One is to make sure the Entity Model class are public. The other is to check the Entity Model Namespace is matches to the Context class.


I was able to resolve it by deleting the existing edmx file and regenerating a new one.

Apparently the old one got into a weird state, I was not able to figure out how to get it to work again.


I have used Entity Framework for DAL in a few projects but in the one I'm working on right now, I have the edmx file in a class library project and that's all there is in the project. I have this project referenced in another class library project where i was not able to initialize the object for the entity class saying connection string was not set ,where i have checke with the connection string which was there.\


check your inherited class of DbContext, it must be public


Check the Namespaces of the Context class and Designer.cs class.

0

精彩评论

暂无评论...
验证码 换一张
取 消