Last post Aug 19, 2014 10:12 PM by stateofreason
Aug 14, 2014 02:10 PM|stateofreason|LINK
Quick question - I have noticed that, on occasion, the Dbcontext-derived class is not being auto-generated when using the code-first from existing database process. This is VS2013 Premium. Has anyone else experienced this problem? Any ideas?
Aug 14, 2014 02:46 PM|MetalAsp.Net|LINK
As far as I know (far from being an export) with code first you create the dbcontext and add your DBSets yourself.
Aug 14, 2014 03:00 PM|stateofreason|LINK
Thanks...yet when I create them they sometimes automatically generate the dbcontext. Also, per this video, it should automatically be created:
Aug 14, 2014 10:28 PM|Kevin Shen - MSFT|LINK
Thanks for you post here.
When you try to use code first from existing database,it will auto generate a yourown dbcontext class derived from DbContext.
I suggest that you can try the link below which explain how to code first from existing database step by step:
If you still have problem,please feel free to me.
Aug 15, 2014 08:57 AM|stateofreason|LINK
I realize this is how it is supposed to work. And, sometimes, it does generate the dbcontext class automatically. In other cases it does not. So far I haven't been able to find a rhyme or reason for it.
Aug 17, 2014 09:52 PM|Kevin Shen - MSFT|LINK
Please explain in which situation entity framework didn't generate the dbcontext class automatically for you.
It will be better ,if you can share your project in the onedrive(https://onedrive.live.com/?gologin=1&mkt=en-US)
Aug 19, 2014 10:12 PM|stateofreason|LINK
Thank you Kevin; in all honesty I cannot. In one case I was doing a demo for a customer whereby I created a new Entity Model (code first) the same exact way I had done it 3 times before in the same demo and the class was not created. In another I was doing
a remote development session with another developer and he commented on the class not being generated. I retraced the same steps and it was created. I haven't found a lot of information on it online so perhaps it is something with my installation of VS. If
I can recreate the project I will upload it as is.