Skip to main content

Posts

Showing posts with the label edmx

Entity Framework - Suporte para múltiplas BD

Uma das limitações que o EF ainda tem é o seu suporte para múltiplas bases de dados. A opção simplesmente não é suportada à partida, apesar de atrair muitos votos no UserVoice . Antes de mais, quero dar crédito aos autores da ideia original. Esta ideia não  foi minha. Eu fiz download do script original, utilizei-o e depois reescrevi-o quase  completamente para lidar com alguns casos adicionais. Eu adoro Linq, por isso aproveitei para utilizar bastante na nova versão. O script original pode ser encontrado aqui . O truque é fazer o EF acreditar que todas as tabelas/objectos mapeados estão na mesma base de dados utilizando sinónimos. Eu não sei se todas as BD's suportadas pelo EF têm alguma feature semalhante a sinónimos, mas isto é certamente possível no SQL Server (que eu estou actualmente a usar). O meu script acrescenta a possibilidade de primeiro fazer backup dos ficheiros edmx  (algo que eu acho útil para evitar que o meu modelo fique corrompido), substitui os pr...

Entity Framework–Multiple Database support

One of the limitations that EF still has is the support for multiple databases. It simply does not support that option.out of the box. Allthough on UserVoice a lot of people have voted this feature, it still doesn’t exist. Credit where credit is due: this is not my original idea. I first downloaded the original script, used it and then i almost completely rewrote it to suit my needs and to improve certain aspects. I love Linq, so i used it a lot. The original and fantastic script can be found here The trick is making EF believe that those objects are in the database by using synonyms. I dont know if every EF-supported database allows synonyms or not, but this is possible in SQL Server (which i am using).   My script adds the ability to backup the edmx files first (which i find useful to prevent my model from being corrupted), replace the prefixes in the resulting model (which i had to do by hand with the other script) and finally reorder the navigation properties by al...