How can I use stored procedures in SubSonic 3.0.3? - stored-procedures

I have a problem in SubSonic 3.0.3. When I use SubSonic to generate code, I can use all the tables in the database, but I can't see any of the stored procedures which had been defined in database.
Please help.
P.S. : I am using MSSQL

Make sure you are including the StoredProcedures.tt file. Running the t4 should generate the code for you to use stored procedures.

Related

EF6 Updating Code First Model from the Database

I inherited an ASP.NET MVC application using Entity Framework 6.2. The application was originally built using Code First and I can see migrations that have been applied to the database. The structure of the database seems accurate.
However, a ton of relationships have been added to fix referential integrity issues and these were done directly on the database. There are a bunch of them. Can someone help me to update the models from the database in a code first implementation? Ideally it would remain code first, not a conversion, but I need to do a one time update.
I'm more familiar with newer EF Core and I thought it would as easy as running a scaffold-dbcontext command with a -force and some cleanup. But no such luck in this older version. Is there something similar?
Depending on what a 'ton' means and whether you need to keep the old migrations you could either just rebuild the entire model by doing code first from existing database or you could save the generated code into a folder and do a manual reconstruction:
Run code first from existing database into a new folder.
Map new fields and navigation properties into existing models.
Fix up any fluent code (modelBuilder).
Generate a migration which should include those changes.
A good test would be restoring a pre-change version of the database and running the migration against it. Then perhaps use a schema compare utility.
Apply the migration to databases. If the database already includes the changes, comment out the Up() code before applying. This will update the stored model so the next migration does not repeat these changes.

Generating Entity Pocos from Existing Database

Using code-first, is there a way to generate entity classes from an existing database? I get how to use migrations. I get how to update a database with migrations. What I don't know is how to create a model set from an existing database that was created before migrations was a thing. I have a lot of tables.
What is the appropriate work flow here? I would really rather not write these by hand.
NOTE: I CANNOT USE AN EDMX. So do not register this as a duplicate of the thousand questions that say "just create an edmx file."
I'm moving a major legacy project over using Code First to an existing database. https://msdn.microsoft.com/en-us/data/jj200620.aspx. First thing I did was modify the default templates so I minimize the changes needed to namespace, etc. (I move the classes to other project after generating them). https://msdn.microsoft.com/en-us/data/jj593170.aspx Then I reverse engineer in small groups of related tables, create a migration, verify everything in the Up() code matches my database, comment the Up() code out and update the database. You could also add a migration with -IgnoreChanges, but I like to see the code. After a while I roll all the little migrations into a single migration using this technique http://cpratt.co/migrating-production-database-with-entity-framework-code-first/#at_pco=smlwn-1.0&at_si=54ad5c7b61c48943&at_ab=per-12&at_pos=0&at_tot=1.
Some of the referenced links mention EF Power Tools, but I don't believe I needed to install those to reverse engineer (VS 2013, EF 6.1.2). I did need to install this Nuget package for the templates: https://www.nuget.org/packages/EntityFramework.CodeTemplates.CSharp/

Beginner Ruby on Rails: Migrating an existing psql database

So basically I am making a new sample application that will run using an external Postgres database and a model, both created by another programmer who has given me this project.
I am supposed to create a rails app that will implement the model and database in order to add some mapping functionality. The problem is that I truly do not know how to migrate an existing database using the "db_name.sqldump" file they provided me. I have installed psql, created a new rails app and added the "pg" gem, but I haven't been able to create a table with all the model information.
I am not sure if I am being clear but I truly am pretty much lost here with RoR. Any input would help.
Assuming you've a pg_dump file, import it from the command line using either of psql or pg_restore.
http://www.postgresql.org/docs/current/interactive/app-pgrestore.html
Follow this railscast by Ryan Bates - http://railscasts.com/episodes/342-migrating-to-postgresql
To convert your sqldump to a sqlite db, Follow these guides : -
script to convert mysql dump sql file into format that can be imported into sqlite3 db
http://code-n-fold.com/2011/11/28/convert-mysql-dump-to-sqlite-format/

Generate XML Schema for Domain Classes in Grails

Could you please suggest a service or plugin which generate the corresponding XML Schema for a given Domaing Class or for all Domain Classes of Grails project.
This plugin does exactly what you're asking.
http://grails.org/plugin/domain-schemagen
You just need to type the following command shell from your project root directory:
> grails schema-export
See schema-export documentation for further details
It will generate a DDL file.
From there, you need to convert it into XML (if you really want XML).
I recommend using a database migration to control all the schema generation and to manage future changes. We use Liquibase, it's very easy to use and flexible and there is already a Grails plug in for it. All the changes in Liquibase are managed in XML format.
Also, if I am not mistaken database migrations are going to be integrated in Grails core for version 1.4 so you will be able to use schema migrations without having to install any plug in and I think with this you would be able to manage your changes using DSL as well.

How can I access an Interbase (.IB) database using RubyOnRails?

I have a database in Interbase and I want to access it directly from my Rails app using ActiveRecord. How can I do it?
There is a gem called activerecord-interbase-adapter although I haven't used it.

Resources