c#mysql查询重复数据结构_.net c#实体框架多数据库项目结构

I would like to know what is the advisable approach on creating a project with multiple database using entity framework.

My current solution projects looks like this.

SystemName.Data // Points to Database1

SystemName.Core // Points to Database1

SystemName.Database2.Data

SystemName.Database2.Core

SystemName.Database3.Data

SystemName.Database3.Core

SystemName.Business

SystemName.UI

Should I put the all the Data and Core assembly in one project?

Should I also create different business projects for each database?

Thanks in advance!

Solutions1

In EntityFramework 6 (EF6), you can use multiple contexts on the same database. In EF5, a single user model (DbContext) is managed by only one database instance.

So, the multiple DbContexts can be in different projects, and use the same database instance in EF6.

Update

The databases used by the DbContext could be decided by app.config (or web.config). So, I prefer to put my sub-classes of DbContext into different projects according to their purposes. If the database maximum size is considered, like 10GB per database, then put one DbContext to one database might be a good choice. But in EF6, the DbContext could be considered as a plugin. If the application needs an extension to gain more abilities, then an extra DbContext will create necessary database for the extension. Some day the extension is not useful, and it needs to be uninstalled, then some tables in the same database will be dropped.

Talk1:

by the way i'm using entity framework 6 in Visual Studio 2010.

Talk2:

I updated my answer. I use EF6 in VS 2012. I like EF6.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值