How to update gobuffalo models with pop? - buffalo

I'm starting a project and already check how useful is gobuffalo/pop.
I have never previously used a framework for my GO projects. I just used the stdlib and I'm used to working with Django too.
In Django it is pretty straight forward to create/update a model and generate its migrations. It gets the current DjangoModel and generates a migration with the changes. What a surprise to me when I can't find how to do it with pop.
I already checked the documentation but I couldn't find any examples.
How do you do that?

Right now, you can only generate empty migrations and write them yourself: https://gobuffalo.io/en/docs/db/migrations#writing-migrations
There's an issue asking to implement a Django-like migrations generator (https://github.com/gobuffalo/pop/issues/184), but it's not done yet and requires a lot of work.

Related

Can't upgrade SQLite model to EF Core 2 due to AddForeignKeyOperation

I'm trying to upgrade my app to ASP.NET Core 2, with EF Core 2 (and SQLite), in other words netcoreapp2.0. I followed the upgrade guide.
I also recreated migrations, and noticed the new ones are quite different from the ones I remember from 1.1 (different commands sent to the db, different syntax, etc). But my model is the same, and after generating migrations, everything compiles properly.
BUT, when I try to create the db programmatically using context.Database.Migrate();, or manually on the CLI using dotnet ef database update, I get
System.NotSupportedException: SQLite does not support this migration operation ('AddForeignKeyOperation'). For more information, see http://go.microsoft.com/fwlink/?LinkId=723262.
However, I don't use the AddForeignKeyOperation command anywhere in my solution (I searched for it). I searched my migration files, and they don't use that command.
I'm sure it's something basic, but I can't track it down. What could it be?
Turns out the problem was not deleting all migrations.
I had the "initial" migration, then migration1, migration2, etc. The initial migration is from the template, so it had Identity/roles/users/etc. So I left that one alone and deleted/recreated the other ones only (i.e. the ones with my domain model).
Well it turns out that when I deleted ALL migrations, and recreated them, I stopped getting that error.
That error is confusing and poorly worded, and has nothing to do with the problem. Hope this helps someone else.

Reverse engineering a schema from existing database with Slick

I understand that the functionality to reverse engineer a schema from an existing database is in development for slick-2.
Could someone point me to the api for doing this and what the status of this functionality is.
Is it in master or do I need to switch branches? Pointers to any kind of doc for this feature would also be great.
The feature that will make it into 2.0 is in this PR
https://github.com/slick/slick/pull/233
There is no documentation at the moment besides the code. To understand how to use it you will have to look at
the type provider config files
the Scala object GeneratedClasses that uses them to run the code-generator
the part of the sbt build file, that triggers GeneratedClasses during the build
the corresponding test cases
(UPDATE: added links to the source code above)
There is also an older prototype which I wrote taking a different approach for Slick 1.0. bhudgeons wrote a blog post about how he used it https://bhudgeons.telegr.am/blog_posts/slick-tool-for-db-schema-generation
There has been some experimental work going on using type macros, but they wont make it into Scala, so we have to rewrite it for annotation macros at some point.

Data sources toolbox for VS2012 does not display my entity model

After adding an entity model either from the datasources toolbox itself or by adding it => "add" => "new item" it does not show up in the datasources toolbox and therefor i dont get that easy drop and drag functionality.
If I add a dataset it works but that is an older technology (is it not?) everything in my current project are entity models and to change to datasets (which only works if I add xmlns:yourAlias="clr-namespace:WpfApplication3") would be .. I don't think best practice and a waste of time.
I have recreated this same process of adding a entity model in VS 2010 and it works 100%, where i have the ability to simply drop and drag from the dataSource toolbox
Maybe ill just wait for VS SP1 before working with it for client projects. :(
//Edit
If I add the ADO.net Entity model in VS2010 and then load the project in 2012 it loads fine in the dataSource toolbox. This is an answer but not an ideal work around.
While working on a project I recently faced the same problem. It took me about two days of extensive research but I think I've finally found it:
http://msdn.microsoft.com/en-us/data/jj556581
At least for me it solved the problem. Please let me know if it helped you..
Being addicted to L2S, I tried to get familiar with VS2012 and EF5. But I nearly lost my nerves trying to use the data sources toolbox.
Finally I found a solution:
using Object Data Source is now the recommended approach for using EF in databinding scenarios. See this article for more details - http://msdn.microsoft.com/en-us/data/jj574514. The article also includes a link to revert to the old code generation if that is what you desire.

How to debug Entity Framework Proxies?

After a couple weeks experimenting with Entity Framework 5.0 I think I understand the basics. There's two types of proxies - lazy loading only and change tracking. I know how to enable/disable each and when to use them. However, I want to SEE these classes. I want to be able to step into them at debug time and I want to see what the logic actually does. However, since they are runtime-generated, Visual Studio can't debug them. Ideally I'd be able to pre-compile them, but right now I just want to see what they're doing.
I don't think you can actually debug proxies - at least not using Visual Studio. The types are generated on the fly. The code that generates proxies is here: http://entityframework.codeplex.com/SourceControl/changeset/view/190eef267fc7#src%2fEntityFramework%2fCore%2fObjects%2fInternal%2fEntityProxyFactory.cs (note that this is how it is done in EF6 but it has not changed much since EF5). You may also want to take a look at this blog post: http://davedewinter.com/2010/04/08/viewing-generated-proxy-code-in-the-entity-framework/ - with some hacking you will be able to save generated types to disk and use reflector to see the code.

System.Data.MetadataException - seems more stubborn than most people's

I have gone through this post and the links, and still can't solve my issue.
I have changed my config to name the assembly, but it makes no odds.
We recently moved the projects and think that might be an issue - but how to solve it if so. I don't quite understand how EF when running finds the cdsl etc. files I thought they were embedded in the dll [it is set to do so]?
The service having the issue doesn't directly use EF itself, it uses another DLL which DOES. I also added a direct ref to the DLL but no joy.
Also, the same code (the dll that contains the functionality, not the wrapper service) using the same connections strings works fine in my system test project via the IDE.
Turned out to be down to incorrect initialisation of StructureMap and not really to do with EF itself.