开发者

One POCO model with different data providers

I have a client application (WPF, C#, .net4) which uses POCO entity model connected through SQLITE provider. So I want to have same entities from this project in an asp.net project (with MSSQL provider), to use there the same entities that I use in my client application. I want to create some kind of replication functionality between my client app (SQLITE) and web server (MSSQL) using same poco model using web services.

So I have a reference to my entities model in both projects with different connection strings for edmx files. And in this case (because edmx was compiled for sq开发者_开发技巧lite provider) when I'm trying to use mssql data provider I get an exception:

unable to cast System.Data.SqlConnection to System.Data.SQliteConnection

So my question is if it is possible to use different data providers in one entities model? What is the best way to use same model in different projects?


If I understand your question correctly, then if you are looking for your EF model to support multiple database implementations then this is not possible out of the box. The SSDL file auto-generated by EF will contain provider specific metadata and therefore will restrict its independence from the different database implementations you are using.

There are some articles out there providing ways around this, but this requires a separate copy of your model for each provider and hacking the generated XML with the provider details.


with POCO it should be possible. As long as web service is passing xml or json data, it will not be bound to any specific data connector implementation. I am not sure what it will be in binary mode - possibly there's some link to data model. Are you getting this error from WPF app or from web service? It sounds like you are trying to test this inside client app still. Did you try implementing web service yet?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜