Page 1 of 1

Not Specifying the Schema Name

Posted: Fri 15 May 2009 22:26
by Anchor
Hello,

Do you have to specify the schema name in the .edmx file or can you delete it or remove it?

We want to be able to remove any references to the schema so we can use database synonyms defined for a database login user/accout. These synonyms will specify what tables or views to look at/use in what schema.

Can I take, for example, a line like this in the .edmx.....



....and do something like this.....



...??

Thanks in advance for the help.

-- Joe

Posted: Mon 18 May 2009 10:47
by AndreyR
You can safely remove the schema attribute from the model.

Posted: Mon 18 May 2009 14:13
by Anchor
Do you mean I can remove it from the .edmx file or do I remove it from the generated .ssdl file? I just want to make sure I have a clear understanding.

Does this mean that once it is removed, the entity framework, or the database, will use the synonyms of the user to locate the table(s)?

Thanks,
Joe

Posted: Mon 18 May 2009 14:49
by AndreyR
You can remove the schema attribute from the .edmx file.
This will make EF to use the synonyms.

Posted: Mon 18 May 2009 15:47
by Anchor
Thank you for the quick responses!

One thing. Will this work with views as well? Can I just remove the schema name from in front of the view name?

Posted: Mon 18 May 2009 17:18
by Anchor
For example, I have a view that is defined like this....


SELECT
V_529_COLUMN_COMMENTS.COLUMN_NAME AS COLUMN_NAME,
V_529_COLUMN_COMMENTS.COMMENTS AS COMMENTS,
V_529_COLUMN_COMMENTS.TABLE_NAME AS TABLE_NAME
FROM COMMON_OWNER.V_529_COLUMN_COMMENTS V_529_COLUMN_COMMENTS



...and now I have it defined like this....


SELECT
V_529_COLUMN_COMMENTS.COLUMN_NAME AS COLUMN_NAME,
V_529_COLUMN_COMMENTS.COMMENTS AS COMMENTS,
V_529_COLUMN_COMMENTS.TABLE_NAME AS TABLE_NAME
FROM V_529_COLUMN_COMMENTS V_529_COLUMN_COMMENTS


Is this correct?

Posted: Tue 19 May 2009 06:31
by AndreyR
Yes, this definition is correct.

Posted: Tue 19 May 2009 19:01
by Anchor
I tried out these suggestions and they all worked out great! Thanks for the help!

Posted: Thu 21 May 2009 00:05
by mpovidlov
I have an "opposite" question. I use two database instances. Tables in both of them sometimes have the same name. I'd like to read from both instances in the same program, therefore I am trying to generate two ADO.NET Entitity Data models, one per each database connection.
As a result the generated classes are placed into the same namespace (named after my applicatoin name, WindowsFormsApplication1) and their methods clash because the tables and their columns have identical names.
What can I do to keep the generated classes in different namespaces. Should I just rename the namespaces in the model files or there is another more elegant solution?

Posted: Thu 21 May 2009 08:00
by AndreyR
For the .edmx files you should set the Custom Tool Namespace property to the name of namespace you wish
(Solution Explorer->right-click the model file->Properties).
For the .edml files you can simply set the Entity Namespace design time property of the model.