Syncing entities from two different data providers? - c#

This might be a duplicate but I couldn't find appropriate solution,
Server:
SQL Server
Entity Framework
WCF Service
Client
SQLite
Entity Framework for SQLite
WPF
Requirements
I've few common tables in the server and in the client with same table name and same column names.
My task is to delete the data from the client tables and copy the data from the server tables by calling it through my WPF application.
Possible Solutions
Using Microsoft's Sync framework (but data providers are different
so, it may or may not work)
Using traditional approach (removing entity framework) & use Datasets instead.
Are there any better solutions to achieve this Sync functionality?

Related

GraphQL Hotchocolate one schema with EF Core and several databases

We want to create one GraphQL schema using EF Core and Hotchocolate. Our data is in several databases two Azure SQL and one PostgresQL. In the first DB we have descriptive data and in other two real-time pricing data from different data vendors. We need to have one schema where we have a combination of descriptive and pricing information from several data vendors.
What is the best way to configure Hotchocolate server with EF core to get data from those DBs into one schema? It's not a problem to create several schemas but what is the optimal way to have only one without stiching?
Maybe something like this?: https://dejanstojanovic.net/aspnet/2020/november/accessing-multiple-databases-from-the-same-dbcontext-in-ef-core/
And then using DbContext in HotChocolate: https://chillicream.com/docs/hotchocolate/v12/integrations/entity-framework
There is also GraphQL Federation which might be overkill for your scenario, I would view it as more of an enterprise thing. But it´s worth checking out: https://www.apollographql.com/docs/federation/#:~:text=Apollo%20Federation%20is%20a%20powerful,subgraph

Migrating data from 2 different SQL Server databases using console app

I have 2 web applications which are let's say Legacy1 and New1. I have separate DbContext for both applications and separate databases.
Now I want to migrate data from the Legacy1 database to the New1 database. I cannot simply use copy database or export database options in SQL Server. Entities are different and I need to incorporate some logic while migrating data.
I have decided to use .Net Core Console (.Net Framework) project to do this. Do I have to add both DbContexts to this project? Also all the entities which I want to map and do the migration or is there any other way to achieve this.
Finally i found a simple approach to achieve that. I used EF DB First approach to generate edmx files for source and target databases. Which gives me access to corresponding Entities as well.
I Queried source database using source dbcontext and manipulated data as per the requirements and inserted into target database using target dbcontext. I used AutoMapper to map source entities to Target entities.
It was much simpler than i thought earlier. Hope it helps others having similar scenario.

Easiest way to set up a file based database with Entity Framework

I'm developing an application, in part to learn new technologies - in this instance Entity Framework.
I'm using .NET 4.5, Visual Studio 2013. I need some way to store data that doesn't involve running an SQL server on my tired old laptop (not even the lightweight one) and works with Entity Framework. Ideally I would like something that just stores data in a file. I have a few basic requirements:
A simple relational database. Max 10 tables, this is a prototype, so
the tables won't get very big
Ability to design the database in some
sort of GUI tool
Ability to generate Entity Framework database model
from the DB. I don't want to type those in manually.
No proprietary software other than what I'm already using - i.e. I don't own a MS Access license
Something that ACTUALLY
WORKS
I've spent the better part of today trying to get VS2013 to connect me to an SQLite database that I've created. I never got anywhere. SQLite is simply not listed among the available types of data sources. I've read StackOverflow posts about this issue, I'm done trying to make it work. (this is where the frustration you can sense in this post stems from - this is SO not the point of the exercise, yet I've wasted so much time with it)
Is there any other file based database technology I could use?
Your needs are not compatible, the best choice is SQLite but you can not generate model from database and must use EF as CodeFirst .
and your problem with SQLite can easily fixed by using correct provider and configuration : http://www.bricelam.net/2012/10/entity-framework-on-sqlite.html
I suggest you use SQL Server Compact in combination with my free SQL Server Compact Toolbox VS extension:
A simple relational database. Max 10 tables, this is a prototype, so the tables won't get very big
SQL CE supports all standard relational paradigms, and has a max database size of 4 GB
Ability to design the database in some sort of GUI tool
The extension allows you to do this in Visual Studio
Ability to generate Entity Framework database model from the DB. I don't want to type those in manually.
Yes, fully supported
No proprietary software other than what I'm already using - i.e. I don't own a MS Access license
SQL Compact is free and freely distributable

Working with Disconnected Entities, Following "Database first" approach

I'm studying Entity Framework since I'm developing WPF Applications that will be deployed over a LAN, Database in a server and applications in the other machines.
I heard about disconnected entities and I think that's what I need.
One of my problems is that a book that I'm reading develops the idea around the code first approach, but I want to use the database first approach since we want to design the database in sql server, along with stored procedures and triggers, and then use the Entity Data Model wizard to generate the dbcontext.
We don't want to modify the model generated by the wizard, where can I find easy documentation about this topic?
Thanks in advance
Rafael

EF5 and .net 4.5

I'm thinking about this scenario.
In desktop application I will create EF STE enity. App will be using EF 5 and .NET 4.0.
This entity will be send through WCF to server where will be .NET 4.5 and also EF5.
Is this supported scenario? (i'm failing to find anything useful) I would like to have performance benefits in .net 4.5 on server side.
Thank you.
If the desktop application is also doing things to a database I'm going to assume it's a different one than is on the server. You'll still want to convert complex entities into simpler ones. For instance if you have an entity that contains a list of other entities that you know already exist on the server, translate that into a message entity (by convention just append Message to the entity name i.e. EntityName -> EntityNameMessage) before sending it over the wire by selecting the Ids from the original entity when you translate, rather than the list's entire contents. This would be one way to gain performance.
Alternatively you're using the same database on the client and the server, which is probably a bad practice since you would have to recycle EF on the server every time the client updated an entity in its database, since EF wouldn't know about the change.

Categories

Resources