Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

After upgrading our project from using Entity Framework 5 to Entity Framework 6 (though NuGets update function) i get the following error on my generated Entities class:

Error 1 The type or namespace name 'Objects' does not exist in the namespace 'System.Data'
(are you missing an assembly reference?)

I understand that this is because the namespace has changed and i can manually fix the error by changing my imports from: using System.Data.Objects; and using System.Data.Objects.DataClasses; To: using System.Data.Entity.Core.Objects;

However the file is generated so i need to reapply this fix after every Update model from Database. Is there something extra to change to get EF to generate the model without this error.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
140 views
Welcome To Ask or Share your Answers For Others

1 Answer

I think your problem is, that your T4 templates, which generate the entitties and the context are still in EF version 5.

First you have to delete the current code generation items, which are in the code behind of the model, namely <Modelname>.Context.tt and <Modelname>.tt.Next add a new EF version 6 code generator with Right click in the model designer-> Add Code Generation Item ... -> EF 6.x DbContext Generator.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...