项目作者: AscarGb

项目描述 :
Implementation of the anchor modeling for Entity Framework Core as a Fody plugin
高级语言: C#
项目地址: git://github.com/AscarGb/AnchorModelingFramework.git
创建时间: 2020-01-18T20:25:32Z
项目社区:https://github.com/AscarGb/AnchorModelingFramework

开源协议:

下载


AnchorModelingFramework

Implementation of the anchor modeling for Entity Framework Core as a Fody plugin.

AnchorModeling.Fody

NuGet

AnchorModeling.Libraries

NuGet

AnchorModeling.Extensions

NuGet

Quick start tutorial

The example uses Visual Studio 2019

First you need to create a database model as in this example

Next install the following packages:

  1. <ItemGroup>
  2. <PackageReference Include="AnchorModeling.Fody" Version="0.9.5" ></PackageReference>
  3. <PackageReference Include="AnchorModeling.Libraries" Version="0.9.5" ></PackageReference>
  4. <PackageReference Include="Fody" Version="6.1.1">
  5. <PrivateAssets>all</PrivateAssets>
  6. <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
  7. </PackageReference>
  8. <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.3" ></PackageReference>
  9. <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" ></PackageReference>
  10. </ItemGroup>

Make sure the FodyWeavers.xml file is added:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
  3. <AnchorModeling ></AnchorModeling>
  4. </Weavers>

Now rebuild the project. In the output you will see:

  1. 1> Fody/AnchorModeling: Constructing entities...
  2. 1> Fody/AnchorModeling: Take entity: User
  3. 1> Fody/AnchorModeling: Make ancor: A_Users
  4. 1> Fody/AnchorModeling: Make attribute: P_Users_Name
  5. 1> Fody/AnchorModeling: Take entity: Computer
  6. 1> Fody/AnchorModeling: Make ancor: A_Computers
  7. 1> Fody/AnchorModeling: Take entity: MotherBoard
  8. 1> Fody/AnchorModeling: Make ancor: A_MotherBoards
  9. 1> Fody/AnchorModeling: Make attribute: P_MotherBoards_Name
  10. 1> Fody/AnchorModeling: Take entity: Processor
  11. 1> Fody/AnchorModeling: Make ancor: A_Processors
  12. 1> Fody/AnchorModeling: Make attribute: P_Processors_Name
  13. 1> Fody/AnchorModeling: Take entity: RAM
  14. 1> Fody/AnchorModeling: Make ancor: A_RAMs
  15. 1> Fody/AnchorModeling: Make attribute: P_RAMs_Name
  16. 1> Fody/AnchorModeling: Take entity: SoundCard
  17. 1> Fody/AnchorModeling: Make ancor: A_SoundCards
  18. 1> Fody/AnchorModeling: Make attribute: P_SoundCards_Name
  19. 1> Fody/AnchorModeling: Take entity: VideoCard
  20. 1> Fody/AnchorModeling: Make ancor: A_VideoCards
  21. 1> Fody/AnchorModeling: Make attribute: P_VideoCards_Name
  22. 1> Fody/AnchorModeling: Make attribute: P_VideoCards_Bytes
  23. 1> Fody/AnchorModeling: Make tie: T_H_Users_HomeComputer_to_Computers
  24. 1> Fody/AnchorModeling: Make tie: T_H_Users_WorkComputer_to_Computers
  25. 1> Fody/AnchorModeling: Make tie: T_H_Computers_MotherBoard_to_MotherBoards
  26. 1> Fody/AnchorModeling: Make tie: T_H_Computers_Processor_to_Processors
  27. 1> Fody/AnchorModeling: Make tie: T_H_Computers_RAM1_to_RAMs
  28. 1> Fody/AnchorModeling: Make tie: T_H_Computers_RAM2_to_RAMs
  29. 1> Fody/AnchorModeling: Make tie: T_H_Computers_SoundCard_to_SoundCards
  30. 1> Fody/AnchorModeling: Make tie: T_H_Computers_VideoCard_to_VideoCards

These are the new types that have been added to the assembly.

Now create a console application and add a link to the project with the model and the AnchorModeling.Libraries package.

Then unload the project with the model

When you insert data into your entities, the data will be automatically saved in the anchor model.
See an example.