|
Now, now, don't take it too personally, you can't help it being born in that country
|
|
|
|
|
Brilliance again. I'm dazzled.
|
|
|
|
|
0) Use ADO.Net Data Entity Model because EF6 is NOT stored proc friendly when creating models.
1) Create a model so we can use existing stored procs. Surprise! ADODEM doesn't know how to create a model when you return a dataset selected from a temp table (or dynamic sql), or a stored proc with invalid sql, and doesn't even give you the courtesy of telling you these problems exist. It simply doesn't create an entity and lets you figure out what's missing and why it wasn't picked up. Our existing databases have HUNDREDS - maybe even THOUSANDS - of stored procs, and it's impossible to know what's missing without a tedious comparison between what we expected and what we got back.
2) Once a stored proc or table is imported into your model, ADODEM will not make it available for importing into the same moel. That's all well and good, but...
3) ADODEM does NOT update the model correctly. If you change a stored proc, and try to "update from database", it doesn't detect the changes in the returned dataset. If you delete the resulting entity, and try it again, it doesn't see the stored proc because (I think) the dbcontext already has an entry for it. If you delete bith the dbcontext method and the entity, and then re-add the stored proc, it adds an incrementing number to the end of the entity name.
4) If you annotate the properties of a generated entity, and then for whatever reason decide you need to update that entity, kiss your annotations goodbye.
There are more issues I've discovered, but you guys' attention spans are alarmingly short, so, my only recourse is to
0) Allow ADODEM to fail at being a productive tool. At this point, it saves a little time because I don't have to generate the initial models by hand.
1) Create a ViewModel version of ever ADODEM-generated entity so I can implement annotations.
2) Write a method that will use reflection to move data from the model to the viewmodel entity.
3) Hope/pray that the models only need to be created and not updated, because I think it would be easier to manually update the models that to update them with the built-in functionality.
Voyages of discovery aren't nearly as fun when they expose flaws in the matrix.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
EF isn't intended for use with SPs. If you have a thousand pre-written SPs and insist on working with them then you're using the wrong technology, that's not the fault of EF, use ado.net instead.
As for updating the auto-generated classes, again you're not supposed to. They are marked as partial so any edits you want to do can be done on your own partial class that you have to create yourself.
|
|
|
|
|
You can't annotate properties in partial classes. Being partial is pointless in that regard. Now, if they made all the entity properties virtual, I could just inherit the generated entity and override the properties with annotations. That would be a billion times more useful.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
modified 30-Mar-19 13:53pm.
|
|
|
|
|
|
Thanks, I didn't know about that. I'll give it a shot. (But EF6 still sucks today.)
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
NHibernate is the name of the shining magic bullet that will make all your pain go away, he he
|
|
|
|
|
We can't use nHibernate - it's not on the ASL.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Lucky you, I was coerced into using it where I work
|
|
|
|
|
|
... are teasing an anteater by taunting and then running away, ducking into an anthill ahead of his tongue and then emerging to do the same thing again to the anteater's frustration.
They ran into a third ant, who was vegging out watching baseball and suggested he get in on the fun.
He stretched in his recliner, yawned, and settled back again: "Nah ... that sounds too much like aardvark to me."
Where the heck is me coat?
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Adam Ant would have loved this joke
|
|
|
|
|
So I've got this web app, EF Core with (automatic) Migrations, Azure AD authentication and an Azure Key Vault.
All works fine on my machine (of course), but now I deploy to Azure and it all goes to hell.
No problem, I'll check my logs... Except there aren't any!
I'll check Application Insights, but nothing!
I'll remove lines one by one until the app starts working... (Old school "debugging"!)
It's not EF Core Migrations and it's not Azure AD authentication, those work fine.
I've traced the line to b.ConfigureKeyVault() in the Program.cs.
So... try catch around it, log the exception and go!
EXCEPT IT WON'T FRIGGIN LOG ANYTHING!!!
The application just stops and that's it.
I get a generic HTTP Error 502.5 - Process Failure.
When I remove the line I get some logging I added in case everything succeeds.
When I add the line the application crashes again, it won't hit my catch and everything stops.
I can't debug it remotely as the app isn't running to begin with.
I've checked the key vault permissions and those should be ok.
This issue has cost me a day now and it's really pissing me off!
|
|
|
|
|
Application.ThreadException ?
Message Signature
(Click to edit ->)
|
|
|
|
|
I FOUND IT!!!
When I move my key vault config from appsettings.Development.json to appsetings.json everything works.
Probably because the Development.json is read after Program.cs, but the connection string for the database is in the key vault.
So in Program.cs I do my EF Core Migration, which is trying to read a connection string that isn't there (yet).
There was also an error in the key vault access policies.
Apparently, I had two app registrations with the same name, one I made, and one Azure generated (the MSI).
The key vault needs access to the MSI, not my own app registration.
The problem is that the generated MSI is not visible in the Azure AD, so it's kind of hard to check, but it does show up in the key vault.
Still no idea why everything worked locally though...
Perhaps it reads the Configuration differently in Azure?
All in all, I've learned a lot and I hate the world just a little bit more
|
|
|
|
|
|
My nephew is in year 1. He is 5 years old. He want me to buy him a book on meteorite for his birthday present. I am looking on google but failing to find something decent.
I want to buy one with lots of images but also with acutal description of meteorite. Any suggestion on such book?
Zen and the art of software maintenance : rm -rf *
Maths is like love : a simple idea but it can get complicated.
|
|
|
|
|
|
That one seems very down to earth.
Socialism is the Axe Body Spray of political ideologies: It never does what it claims to do, but people too young to know better keep buying it anyway. (Glenn Reynolds)
|
|
|
|
|
|
Thank you for your suggestion. I bought this one.
Zen and the art of software maintenance : rm -rf *
Maths is like love : a simple idea but it can get complicated.
|
|
|
|
|
Footfall?[^]
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
Lucifer's Hammer would probably be a "better" choice...
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
The problem is in deciding which one contains the most trite "user experience" in reading them.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|