Update model (edmx) with system tables (SYS.xxx) -

2019-09-16 19:07发布

问题:

When selecting 'update model from database' none of the system tables (SYS. schema) is available from the list of tables.

How may I add a system table to my EF model.

Sybase (ASA12) is the database platform which I am using.

回答1:

As a workaround I created a view on the system table. It is then available and may be updated automated by the edmx generator



回答2:

I created a script that recreates all the catalog views, i.e. sys.*, as views in a user schema:

Note: This is T-SQL, and SQL Server object names, but I'm sure you can adapt the concept to Sybase.

SELECT
    'CREATE VIEW ' + 'dpc.' + name + ' AS SELECT * FROM ' + 'sys.' + name + char(13) + char(10) + ' GO' + char(13) + char(10)
FROM 
    sys.all_objects 
WHERE
    type = 'v' 
    and is_ms_shipped = 1
    and schema_name(schema_id) = 'sys'
ORDER BY 
    name

Then I ran the script output by the above query, which copied each sys.x view to a new dpc.x view, and added all the dpc.* views to my EDMX model.