C# 用于办公室管理应用程序无缝集成(并最终替换)的复杂(多模式)实体框架对象映射

C# 用于办公室管理应用程序无缝集成(并最终替换)的复杂(多模式)实体框架对象映射,c#,sql,entity-framework,domain-driven-design,foxpro,C#,Sql,Entity Framework,Domain Driven Design,Foxpro,我是一个相当新手,热心的程序员。这是我的第一个问题,但几个月来我一直在使用stackoverflow来获取有价值的信息 首先,一些背景: 我目前在一个非常小的(因为你有“自由统治权”的职位上工作,有点像是万事通我想借此机会升级整个系统。这是一个非常糟糕的数据模型,再拖下去真的没有用了。这些不起眼的重复编号字段将是混乱和错误的持续来源。从中几乎不可能构建一个像样的域。实体框架有很多有许多选项可以使类模型的形状与数据模型的形状不同,但这太多了。实际上,在保留数据模型的同时重建应用程序是没有用的 您肯

我是一个相当新手,热心的程序员。这是我的第一个问题,但几个月来我一直在使用stackoverflow来获取有价值的信息

首先,一些背景: 我目前在一个非常小的(因为你有“自由统治权”的职位上工作,有点像是万事通我想借此机会升级整个系统。这是一个非常糟糕的数据模型,再拖下去真的没有用了。这些不起眼的重复编号字段将是混乱和错误的持续来源。从中几乎不可能构建一个像样的域。实体框架有很多有许多选项可以使类模型的形状与数据模型的形状不同,但这太多了。实际上,在保留数据模型的同时重建应用程序是没有用的

您肯定应该规范化数据模型。创建表,如
Insclass
,外键为
acttype
,等等。还有一个
Benefit
表,其中FK为
InsurancePolicy
,因为您无法将字符串数组映射到数据库列


但首先(也是最重要的)要弄清楚需求。完全自由地构建“任何类型的应用程序”听起来不错,但用户总是有一些想法。在你输入一行代码之前,我会花足够的时间来思考。首先商定要做的事情。然后开始一个接一个地构建应用程序用例。让他们测试每个用例。这将给他们时间来适应新系统,并慢慢从旧系统中分离,以及在进行过程中对需求进行微调。(简而言之,这是敏捷开发)。

我认为这个问题可以通过一个示例更好地说明如何使用旧数据库的一部分。EF的概念模型(类模型)可以不同于数据模型,但在一定范围内。您可以实现继承、执行表或实体拆分等操作,或者使用复合类型和其他一些操作。但是没有示例就很难给出建议。顺便问一下,医疗数据通常有EAV设计。这里也是这样吗?谢谢您的快速回复Arnold先生。I为我的原始问题添加了一些额外的上下文和一个相当具体的示例。无论我如何划分我的新概念模型,数据对象的继承和关系基本上应该是相同的(聚合根应该是相同的)。从我的理解来看,EAV更像是一个EMR(当前的应用程序没有实现),但在免费的表中仍然有它的迹象…我只是不知道这是设计模式还是在这种情况下纯粹的糟糕设计。简单的回答是,你可以从一个应用程序访问不同的模式和不同的数据库。获取知识可以通过几种方式完成。书籍(如Julie Lerman/OReily和她的实体框架书)订阅学习视频和示例代码培训网站,如PLuralsight。或免费网站,如。还有EF powertools,允许您反向编码优先访问现有数据库。@philsoady谢谢。我知道/一直在使用EF powertools。我目前正在查看PLuralsight,发现它总体上非常有用。感谢您的合作继续协助Gert。我很确定我没有疯狂地认为遗留数据库做得很差。我完全按照你的建议,但我认为我的情况比你想象的更不寻常。我的工作首先是一名医疗技术人员,我有一个生物科学学位来支持这一点。我也支持bill我是敏捷客户和开发人员。我的老板(医生)有最终决定权,但如果我能提高办公效率,我可以这样做。续-关于遗留系统,我从来没有不打算最终完全取代它。我关心的是过渡。我远非专业软件开发人员,所以作为一个业余爱好者,在空闲时间做这件事,我很难说服自己一个独立的开发计划比一个集成的计划更有效。在我开发的过程中能够实现小模块,这将更容易让办公室的其他人相信需要进行更改。此外,至少,我需要进行一次性转换以获得遗留数据。
public partial class Accttype
{
    public decimal Acct_Type { get; set; }
    public string Acct_Desc { get; set; }
    public string Sb { get; set; }
    public decimal Fee { get; set; }
    public bool Acptasgn { get; set; }
    public decimal Insclass1 { get; set; }
    public decimal Insclass2 { get; set; }
    public decimal Insclass3 { get; set; }
    public decimal Insclass4 { get; set; }
    public decimal Insclass5 { get; set; }
    public string Acct_Grp { get; set; }
}
public partial class Zip
{
    public string Zipcode { get; set; }
    public string City { get; set; }
    public string St { get; set; }
    public string Areacode { get; set; }
    public decimal Ext_From { get; set; }
    public decimal Ext_To { get; set; }
}
public partial class Patins
{
    public decimal Custid { get; set; }
    public decimal Inskey { get; set; }
    public string Insurcode { get; set; }
    public string Insurnum { get; set; }
    public string Groupnum { get; set; }
    public string Guarlname { get; set; }
    public string Guarfname { get; set; }
    public string Guarmi { get; set; }
    public string Guargen { get; set; }
    public string Guaraddr { get; set; }
    public string Guaraddr2 { get; set; }
    public string Guarcity { get; set; }
    public string Guarst { get; set; }
    public string Guarzip { get; set; }
    public string Guarcountr { get; set; }
    public string Guarphone { get; set; }
    public string Guaremail { get; set; }
    public System.DateTime Guardob { get; set; }
    public string Guarsex { get; set; }
    public string Guaremp { get; set; }
    public decimal Relation { get; set; }
    public System.DateTime Startdate { get; set; }
    public System.DateTime Enddate { get; set; }
    public bool Active { get; set; }
    public string Bcpc { get; set; }
    public string Auth1 { get; set; }
    public string Auth2 { get; set; }
    public string Auth3 { get; set; }
    public decimal Billcnt { get; set; }
    public string Desc1 { get; set; }
    public string Desc2 { get; set; }
    public string Desc3 { get; set; }
    public decimal Visits1 { get; set; }
    public decimal Visits2 { get; set; }
    public decimal Visits3 { get; set; }
    public System.DateTime From1 { get; set; }
    public System.DateTime From2 { get; set; }
    public System.DateTime From3 { get; set; }
    public System.DateTime To1 { get; set; }
    public System.DateTime To2 { get; set; }
    public System.DateTime To3 { get; set; }
    public string Insnote { get; set; }
    public string Char1 { get; set; }
    public string Char2 { get; set; }
    public string Char3 { get; set; }
    public string Char4 { get; set; }
    public string Char5 { get; set; }
    public string Char6 { get; set; }
    public string Char7 { get; set; }
    public string Char8 { get; set; }
    public string Char9 { get; set; }
    public string Char10 { get; set; }
    public System.DateTime Date1 { get; set; }
    public System.DateTime Date2 { get; set; }
    public decimal Num1 { get; set; }
    public decimal Num2 { get; set; }
    public string Createby { get; set; }
    public System.DateTime Createdt { get; set; }
    public string Modifyby { get; set; }
    public System.DateTime Modifydt { get; set; }
    public string Cobmemo { get; set; }
    public System.DateTime Dinju { get; set; }
    public System.DateTime Dsimbd { get; set; }
    public System.DateTime Dsimed { get; set; }
    public string Createtm { get; set; }
    public string Modifytm { get; set; }
    public bool Archive { get; set; }
    public bool Delflag { get; set; }
    public decimal Coinsded { get; set; }
    public decimal Outpoc { get; set; }
    public System.DateTime Lastupd { get; set; }
    public decimal Coins { get; set; }
    public decimal Msp { get; set; }
}
class Patient : Person
{
    int PatientID { get; set; }
    virtual IEnumerable<InsurancePolicy> InsurancePolicies { get; set; }
}

class InsurancePolicy
{
    int PatientID { get; set; }
    string PolicyNumber { get; set; }
    string GroupNumber { get; set; }
    bool IsActive { get; set; }
    DateTime startDate { get; set; }
    DateTime endDate { get; set; }
    int InsuranceCarrierID { get; set; }
    virtual Person Guarantor { get; set; } //all guarantor information accessible via person aggregate root i.e: Guarantor.FirstName
    string GuarantorRelation { get; set; }
    string[] Benefits { get; set; }  //delineated set of benefit descriptions... automatically parse from EDI benefits message?... seperate value object class?... could contain copay/deduc/OoP
    decimal Deductible { get; set; }
    decimal Copay { get; set; }
    decimal OutofPocket { get; set; }
    virtual IEnumerable<Bill> AssociatedBills { get; set; } //all bills associated with policy... could also be InsuranceClaim objects... Automapper Bill->Claim?
}