Entity framework core 具有实体框架核心的NoSQL

Entity framework core 具有实体框架核心的NoSQL,entity-framework-core,Entity Framework Core,我需要实体框架核心的任何NoSQL提供程序。我可以将EF Core版本与MongoDB/Raven或任何东西一起使用吗?对NoSQL数据库提供程序的支持,如Azure Table Storage、Redis和其他(如MongoDB)仍在EF Core团队待办事项中,尚未实施,也不会在Core 1.0.0版本中实施 也就是说,根据,对NoSQL数据库提供程序的支持是团队的一项高优先级功能,将在Core1.0.0发布后的未来版本中发布。(将注释移动到答案,因此我没有劫持@MortezaManavi的

我需要实体框架核心的任何NoSQL提供程序。我可以将EF Core版本与MongoDB/Raven或任何东西一起使用吗?

对NoSQL数据库提供程序的支持,如Azure Table Storage、Redis和其他(如MongoDB)仍在EF Core团队待办事项中,尚未实施,也不会在Core 1.0.0版本中实施

也就是说,根据,对NoSQL数据库提供程序的支持是团队的一项高优先级功能,将在Core1.0.0发布后的未来版本中发布。

(将注释移动到答案,因此我没有劫持@MortezaManavi的答案)

在您的问题中,您引用了EF Core。正如我提到的,我们为许多NoSQL数据源提供了ADO.NET提供者。您可以为我们的任何提供商下载30天免费试用版(或开放测试版,具体取决于数据源)。我在回答的底部包含了当前NoSQL产品的链接

我们的知识库中有一篇文章介绍了如何使用代码优先的方法(尽管这些原则可以应用于任何数据源)通过EF6连接MongoDB数据。我已经把这里的内容转录了下来


  • 打开Visual Studio并创建新的Windows窗体应用程序。本文使用带有.NET4.5的C#项目
  • 在Visual Studio的包管理器控制台中运行命令“Install Package EntityFramework”,以安装最新版本的Entity Framework
  • 修改项目中的App.config文件,以添加对MongoDB Entity Framework 6程序集和连接字符串的引用

    设置服务器、数据库、用户和密码连接属性以连接到MongoDB

    <configuration>
       ... 
      <connectionStrings>
        <add name=&quot;MongoDBContext&quot; connectionString=&quot;Offline=False;Server=MyServer;Port=27017;Database=test;User=test;&quot; providerName=&quot;System.Data.CData.MongoDB&quot; />
      </connectionStrings>
      <entityFramework>
        <providers>
           ... 
          <provider invariantName=&quot;System.Data.CData.MongoDB&quot; type=&quot;System.Data.CData.MongoDB.MongoDBProviderServices, System.Data.CData.MongoDB.Entities.EF6&quot; />
        </providers>
      <entityFramework>
    </configuration>
    

  • 免责声明:我是这个开源项目的所有者和运营商

    如果您仍在寻找MongoDB EF核心提供程序,您可以在GitHub上找到我的提供程序:。该项目目前包括一个EF核心数据库提供程序和一个ASP.NET核心身份提供程序

    注意:提供程序仍在预览/预发布中,等待EF Core的
    StateManager
    中对复杂类型的适当支持

    您可以通过向项目中添加以下NuGet源来访问包:

    nuget sources add-name EFCore MongoDb-Sourcehttps://www.myget.org/gallery/efcore-mongodb


    请仔细查看。

    谢谢,我看到了Julie Lerman关于Azure table的示例。这意味着我必须稍等一下,否则你有什么诀窍来使用BrightstarDB吗?她的代码示例基于EntityFramework.AzureTableStorage 7.0.0-beta1 nuget包,但它在RC2版本中被删除了,正如你在这里看到的:我认为我们在NoSQL数据库中使用EF Core 1.0.0是运气不佳的,不幸的是。@BassamAlugili如果您能容忍付费解决方案,CData软件(我工作的公司)已经创建了ADO.NET提供程序,允许您创建一个连接到NoSQL源的EF项目,如或。@JerodJohnson感谢您提供的信息。您是否有任何类型的测试版本(大约30天)。现在我收到一个错误:[500]无法执行指定的命令:execmodel.Rowset.execute():集合“Customers”不存在。任何idea@BassamAlugili我很乐意在这里尽我所能提供帮助,但在这种情况下,您可能希望联系我们的,因为他们有更好的设备来帮助您调试您看到的任何特定问题。在过去5分钟内,您可以在添加的视频链接中看到我的测试。我将用EF写一些关于nosql的博客。有一件事对我来说非常重要,那就是我如何才能做到像dbContext.Customers.Include(“Customers.Orders”);我需要customer?BassamAlugili中的嵌套集合最好的答案是使用静态模式。不幸的是,这样做的方式太复杂了,无法做出如此评论。你能联系我们的朋友吗?这是一个关于NoSql和EF的小介绍,我已经用EF 6/MongoDb对其进行了测试。关于EF Core 1.0,正如@MortezaManavi所说,我们必须等到它完成!它支持没有数据丢失的继承模型吗?如果你问的是多态性,那么是的,它支持开箱即用。repo有一个示例域项目和一些测试来演示此功能。但是,请注意,EFCore MongoDB仍处于beta/preview阶段,等待在EF Core 2.0中对复杂类型的适当支持(这是项目构建所依据的版本)。
    using System.Data.Entity;
    using System.Data.Entity.Infrastructure;
    using System.Data.Entity.ModelConfiguration.Conventions;
    
    class MongoDBContext : DbContext {
      public MongoDBContext() { }
    
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
        // To remove the requests to the Migration History table
        Database.SetInitializer<MongoDBContext>(null);  
        // To remove the plural names    
        modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
      }  
    }
    
    using System.Data.Entity.ModelConfiguration;
    using System.ComponentModel.DataAnnotations.Schema;
    
    [System.ComponentModel.DataAnnotations.Schema.Table("Customers")]
    public class Customers {
      [System.ComponentModel.DataAnnotations.Key]
    
      [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
      public System.String _id { get; set; }
      public System.String CompanyName { get; set; }
    }
    
    public class CustomersMap : EntityTypeConfiguration<Customers> {
      public CustomersMap() {
        this.ToTable(&quot;Customers&quot;);
        this.HasKey(Customers => Customers._id);
        this.Property(Customers => Customers.CompanyName);
      }
    }
    
    public DbSet<Customers> Customers { set; get; }
    
    MongoDBContext context = new MongoDBContext();
    context.Configuration.UseDatabaseNullSemantics = true;
    var query = from line in context.Customers select line;