Navicat, Object DB and Postgres - database-connection

I'm importing tables by Navicat Import Wizard (via ODBC connection) in Postgres. I have a problem when import from Caché Intersystem DB a table which allow object list-object.
Example table Test
Id (int),
Name (varchar(10)),
Preferences (List <Objects>)
How could i manage Preferences column without change my schema? There are some features in Navicat Wizard Import?

I haven't find a solution right now. I have import my data as string pipe separated and i have managed collection data list using custom objects by Hibernate.

Related

SQL Server Collations In EF Core

How can I specify the collation of a column, a table, or a database by using annotation or Fluent API? I know there are some clean ways for MySql Provider. However, I couldn't find any way for SQL Server other than executing a raw SQL command.
UseCollation() for database and column levels was added to EF Core 5.
Looks like it will not be done at all:
Here is the closed Issue in aspnet/EntityFrameworkCore: CodeFirst: Set column collation
We discussed and concluded that setting different collations per column isn't a very common requirement and it's probably not something we would make first class in EF. This would be a good candidate for using annotations to define additional metadata and then extending our SQL generators to process those and specify collation.
The only solution seems to be this one: Entity Framework Code First - Change Table Column Collation
... you can create custom database initializer and execute ALTER TABLE command.
Although it is possible to change the collation of the database after creation (while there are some data in its tables), it is better to set the collation of the database before creating any tables.
So in EF core for creating database initially before creating any table:
It is better to make sure you have not added any DbSet in the DbContext file of your project.
Open the Nuget Package Manager
Run this code
PM> add-migration CreateDatabase
Right now an empty Up and Down method is created in a migration file like this:
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
Write this code in the Up method. Make sure your collation Name is correct.
migrationBuilder.AlterDatabase("CollationName");
//or
migrationBuilder.Sql("EXEC('ALTER DATABASE [POMADB] COLLATE CollationName ');", suppressTransaction: true);
Run this code
PM> update-database
I have tested this code in .NET Core 5, Visual Studio 2019, Ef core 5.0.9
For further information look at this link Ability to specify database collation

Entity Framework Database First Approach

I am working on a project in which I am assigned to implement database first Approach. Here, I want to know that when we initiate database first approach we map that to an existing DB, but what if I have another DB with the same structure but different data, can I use that DB by just changing the connection string ? or will it impact somehow?
It will work when you change the connection string. I recommend you select the 'Code First from database' when creating new 'ADO.NET Entity Data Model' with VS add new item.

Change Grails GORM format without dropping existing tables

I have one Grails application that has been running for a while. But now I want to change the GORM format and I wonder if there are simple ways to do so, i.e. ways that I don't need to drop existing tables, only modifying my application will do.
To be specific, I used to have one HashSet field that is mapped to varbinary in DB. There are some existing rows in this User table.
public class User{
//irrelevant attributes omitted
HashSet<String> friends=new HashSet<>();
static mapping={
friends sqlType: 'VARBINARY(10000)'
}
}
Now I've changed the field friends to a HashMap<String,Integer>. Now although I still map the field to varchar, Grails throws an exception every time I save an User object:
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
I first suspected that Grails keeps the old converting rule transforming HashSet to varbinary and it wasn't updated. So I tried changing the mapping from varbinary to blob and text, but neither worked.
I'm wondering if there are ways that I keep this column in varbinary in DB while letting Grails know that the attribute is now in HashMap and it should generate new ruls to convert.
Appreciate your insightful advice!
Edit: Im using Grails 2.4.4
There is one way I know of doing this: log into the database server so you have access to the database in a term window. Do this first on your development machine. Look at the relevant columns and see exactly which data types they use. Then, on your development machine, drop those columns and deploy the changed project. The new columns will be created if you've got the gorm set to 'update.' Again inspect the relevant columns and see if there's any way of changing the old columns (alter table...) in your production database to the new columns. You'll have to stop your production server, make the changes, deploy the new project and restart it. If you can't just change the columns you may have to create the new ones, move data over and delete the old ones - all with the application server stopped.

Changing Identity 2.0 table names database first

So I managed to merge Identity 2.0 tables in my own database and I also changed the connection string so that now Identity uses my database. I did some test and it works fine.
But how do I change table names?? because I looked over a couple of Identity classes in my project but none of them seems to have any table name inside..
at the moment table names start with AspNet. e.g AspNetUserClames. How do I change it?

EF CTP4 - create tables, but not drop DB

I have a single hosted SQL Server DB and I don't have permissions to drop it. How do I make EF create tables from my domain classes? RecreateDatabaseIfModelChanges and AlwaysRecreateDatabase try to drop DB, CreateDatabaseOnlyIfNotExists doesn't create the tables.
Thx
CreateDatabaseOnlyIfNotExists is the default strategy. It means you don't need to even set it through the Database.SetInitializer. EF Code First will check the database and if couldn't find one with the same name as your context's fully qualified name, it will create one for you.

Resources