efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Scaffold-DbContext doesn't work

Open vsfeedback opened this issue 2 years ago • 5 comments

This issue has been moved from a ticket on Developer Community.


Can we have the old way of doing entity framework database-first back? You know the one where we add a item and select ADO.NET Entity Model. I’ve tried that stupid Scaffold-DbContext several times on different computers with different databases and all it wants to do is [Redacted] the bed. Can you guys test this stuff before you unleash it on the rest of and get rid of a perfectly good option that worked 100% of the time.

I know you hate people who build databases first, but sometimes the databases out last the code bases. Sometimes several code bases, but you guys wouldn’t know anything about that because you all just graduated college a couple of years ago. Now that you’ve ruined it, people with really solid database designs have to go through a [Redacted] load of extra work to get the data model into the project.

I really need to find a better development platform. Your big claim to fame is that you make this stuff so easy. Well, it’s not. It’s just [Redacted]. Code first is [Redacted] because you’re not always building the database with the code. Are you guys really that inexperienced at building software?

Please see screen cap to bear witness. So funny that it’s a null pointer exception after you guys now force us to declare strings nullable to stop null pointer exceptions. Well, it obviously doesn’t work. Yet another mistake on your end.

The other computer was [Redacted] about login issues on SQL Server even though I’m the only one that uses that computer, I’m the administrator, and I’m the user who loaded SQL Server. There is no other user in the entire universe with more permissions on the computer than me. So apparently there is is no freakin way to get your stupid Scaffold-DbContext thing to work. What a piece of [Redacted] you’ve created. Great job! Thanks for making mine miserable.


Original Comments

Feedback Bot on 12/30/2022, 01:53 AM:

(private comment, text removed)

Matt Romine on 1/3/2023, 09:27 PM:

(private comment, text removed)


Original Solutions

(no solutions)

vsfeedback avatar Jan 18 '23 11:01 vsfeedback

Try EF Core Power Tools, even has "Add Item" "wizard"

ErikEJ avatar Jan 18 '23 13:01 ErikEJ

Thanks for providing an alternative, I think. The tool didn't generate a null pointer exception, so that's good. I still can't get over that null pointer exception. Ever heard of a try/catch block? Good candidate for those impending layoffs.

The tool did generate a lot EF code but it's riddled with compiler errors. The biggest one is that it ignores the names of the key fields in the database and creates its own name. Not sure why that's necessary. The actual name of the field is right there in the database just like the other fields in the table. Still, it's better than an embarrassing null pointer exception thrown out of a program written by $1.7 trillion software company.

Anyway, we've already created the EF code manually so we'll need to wait for another project to test this out thoroughly. We could possibly compare what we did manually to what this tool generates, but we'd have to work through all these compiler errors. Yay!

ghost avatar Jan 22 '23 12:01 ghost

Tried it again on small side project for testing. I noticed the setting this time called "User table and column names directly from the database". It cleaned up those errors I mention before. It still had an issue with a many-to-many relationship being referenced in another table, but you can't win them all. I don't remember the old one being very good at these types of relationships either.

This tool is awesome! Thank you. I don't how I got trapped down the scaffold-dbcontext rabbit hole, but I'm so happy to be free of it now.

ghost avatar Jan 22 '23 21:01 ghost

This issue is lacking enough information for us to be able to fully understand what is happening. Please attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate.

ajcvickers avatar Jan 24 '23 17:01 ajcvickers

@aspenroot all the snarky remarks aside, we definitely do support database-first workflows, and a great many users out there are using Scaffold-Context successfully.

As @ajcvickers wrote, what we need is a way to reproduce the exception that you're seeing; ideally that would be a minimal application and database model, that when you execute Scaffold-Context on it, reproduces that.

roji avatar Jan 24 '23 18:01 roji

The snarky comments are a direct result of the frustration I had from hours of trying to get the Scaffold-Context thing to work on multiple computers and databases. The best way to keep a snarky Morlock like me out of your Eloi lives would be to publish software that works and doesn't throw null pointer exceptions. Now, it's obvious I wasn't loved enough as a child and have a lot of misdirected anger, blah, blah, blah. So, I do owe you an apology. I'm sorry for being such a punk.

I'm also sorry I can't help you guys out with Scaffold-Context. I don’t have a dog in this fight anymore. I used the EF Core Power Tools and they worked like a champ. I've already sunk enough time and resources into Scaffold-Context with nothing but a bunch of frustration and snarky comments to show for it. Hopefully, you won't ever hear from me again. I wish you the best of luck debugging Scaffold-Context.

ghost avatar Jan 29 '23 18:01 ghost

That's unfortunate, since the only way we can fix bugs to prevent someone else from running into them is with the help of our users, since we can't fix something we don't know how to reproduce.

In any case, I'm happy the EF Core Power Tools are working out for you, they're great.

roji avatar Jan 29 '23 19:01 roji