[CSHARP-1177] Support for .NET Core Created: 29/Jan/15  Updated: 15/Nov/21  Resolved: 06/Sep/16

Status: Closed
Project: C# Driver
Component/s: Feature Request
Affects Version/s: 2.2
Fix Version/s: 2.3

Type: Epic Priority: Major - P3
Reporter: mickdelaney Assignee: Robert Stam
Resolution: Done Votes: 57
Labels: compatability, coreclr
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on CSHARP-1736 Hostname connect fails on Linux Closed
Duplicate
is duplicated by CSHARP-1763 Net Core Support Driver Closed
Related

 Description   

Support using the .NET Driver from applications built for .NET Core.



 Comments   
Comment by Henning Støverud [ 04/Sep/16 ]

2.3.0-rc1 was released last monday:
https://www.nuget.org/packages/MongoDB.Driver/2.3.0-rc1

Comment by Christian Hüning [ 12/Aug/16 ]

Thanks for the effort! Much appreciated!

Comment by Robert Stam [ 12/Aug/16 ]

Thanks to those of you trying out the 2.3.0-beta1 version of the driver.

Sorry for not announcing the release of beta1 on this ticket. That would have been a good idea. We did announce it on the mongodb-user and mongodb-announce Google Groups.

We are aware of problems with how the NuGet package was built. The package does not correctly declare the dependencies. See:

https://jira.mongodb.org/browse/CSHARP-1733

As a workaround for beta1 you can add the missing dependencies to your own project.json file.

We are also aware with problems with Sockets and DNS names when running 2.3.0-beta1 on .NET Core on Linux (non-Windows machines). This is due to an issue in .NET Core that we need to work around. See:

https://jira.mongodb.org/browse/CSHARP-1736

There is no easy work around for beta1.

We intend to release beta2 as soon as possible.

Comment by Christian Hüning [ 12/Aug/16 ]

Some good news besides: I get 50.000 Writes / sec with dotnet and 2.3.0-beta1 on OSX while I get 14.000 Writes / sec with .net 4.5 on Windows 10 (same hardware used). Very nice!

Comment by Christian Hüning [ 12/Aug/16 ]

The timeout message thrown when using a DNS name indicates that you should use the IP address, because the IP behind the DNS resolution could change and therefore a socket could become invalid.

Comment by George Jreige [ 12/Aug/16 ]

I get a system timeout when I use a DNS in the connection string.... I.e. subdomain.host.com. If I use the IP address it works.

I also had to add in the "System.Security.SecureString": "4.0.0" dependency to get it to work.

Comment by Christian Hüning [ 12/Aug/16 ]

hm I cannot connect to a MongoDB hosted via docker on localhost, when my connection string uses "localhost". When using "127.0.0.1" it works though.

Comment by Christian Hüning [ 12/Aug/16 ]

thanks @Richard i've upgrade my dotnet tools and now it's working. Strange though, that this package restriction in some way is dependant on my dotnet cli version... but that's another topic

Comment by Henning Støverud [ 12/Aug/16 ]

@Christian: That's strange. I'm just using the default feed.

Feeds used:
    https://api.nuget.org/v3/index.json

Comment by Richard Fawcett [ 12/Aug/16 ]

Super excited to see that a beta version of this package has been released for .NET Core. Disappointed that there was no comment on this thread to indicate the release, as the package was released nine days ago!

Christian ... I'd try making sure you have the latest version of the tooling for Visual Studio installed. I was getting some pretty odd error messages until I updated the tooling.

Comment by Christian Hüning [ 12/Aug/16 ]

Thx for sharing your project.json Henning!
I tried that as well, but got an error indicating that MongoDB.Driver 2.3.0-beta1 is not compatible with netcoreapp 1.0 as follows:
Errors in .../DotNetCoreMongoDBTest/project.json
Package MongoDB.Driver 2.3.0-beta1 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package MongoDB.Driver 2.3.0-beta1 supports:

  • net45 (.NETFramework,Version=v4.5)
  • netstandard1.6 (.NETStandard,Version=v1.6)
    Package MongoDB.Bson 2.3.0-beta1 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package MongoDB.Bson 2.3.0-beta1 supports:
  • net45 (.NETFramework,Version=v4.5)
  • netstandard1.6 (.NETStandard,Version=v1.6)
    Package MongoDB.Driver.Core 2.3.0-beta1 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package MongoDB.Driver.Core 2.3.0-beta1 supports:
  • net45 (.NETFramework,Version=v4.5)
  • netstandard1.6 (.NETStandard,Version=v1.6)
    One or more packages are incompatible with .NETCoreApp,Version=v1.0.

NuGet Config files used:
/Users/christian/.nuget/NuGet/NuGet.Config

Feeds used:
https://api.nuget.org/v3/index.json

Did you use another nuget feed or something?

Comment by Henning Støverud [ 12/Aug/16 ]

I tested 2.3.0-beta1 in a new ASP.NET Core Console App. You have to manually add "System.Collections.Specialized" to the list of dependencies. Otherwise you'll get this exception:

Unhandled Exception: System.AggregateException: One or more errors occurred. (Could not load file or assembly 'System.Collections.Specialized, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.) ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Collections.Specialized, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
   at MongoDB.Driver.Core.Configuration.ConnectionString..ctor(String connectionString)
   at MongoDB.Driver.MongoUrlBuilder.Parse(String url)
   at MongoDB.Driver.MongoUrl..ctor(String url)
   at MongoDB.Driver.MongoClient..ctor(String connectionString)
   at Generator.DataGenerator..ctor()
   at Generator.Program.<RunGenerator>d__1.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at Generator.Program.Main(String[] args)

My working project.json looks like this:

project.json

{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  },
 
  "dependencies": {
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0"
    },
    "MongoDB.Driver": "2.3.0-beta1",
    "System.Collections.Specialized": "4.0.1"
  },
 
  "frameworks": {
    "netcoreapp1.0": {
      "imports": "dnxcore50"
    }
  }
}

Maybe add System.Collections.Specialized as a dependency in MongoDB.Driver itself?

Comment by soeng kanel [ 19/Jul/16 ]

we are waiting on this to start the development stage!

Comment by Max Riegler [ 17/Jul/16 ]

It's almost done anyway - only CSHARP-1707 and CSHARP-1557 to go.
I don't think trying to pressure the team will make things going any faster.

Comment by Boler Guo [ 17/Jul/16 ]

We really need this driver, I check this Epic almost every day .

Comment by Robert Stam [ 11/Jul/16 ]

We are actively working on this.

We will release a beta as soon as possible.

Comment by Marco Talento [X] [ 11/Jul/16 ]

I want to upgrade my projects to dotnet core and we are using mongodb

Comment by Ivan Artemov [ 11/Jul/16 ]

Any news ? 8 July ends.
Robert, we every day check progress for this task)

Comment by Richard Fawcett [ 29/Jun/16 ]

Thanks for the quick reply Robert. Really looking forward to putting this through its paces!

Comment by Robert Stam [ 29/Jun/16 ]

For the moment this work is in a separate branch. We are close to being done and as soon as it is code reviewed it will be pushed to master.

Comment by Richard Fawcett [ 29/Jun/16 ]

I was hoping to build the driver for .NET Core, but it looks like I'm not getting the latest and greatest. There's no project.json and a couple of hundred compile errors when trying to compile the source for MongoDB.BSON in a new .NET Core class library. Is this work being done in a separate(non-public) Github branch perhaps?

Comment by Robert Stam [ 25/Jun/16 ]

We're making progress but we do not have an ETA for the 2.3 release which is probably the release that will add support for .NET Core.

Even before 2.3 is released you would have the ability to build the driver yourself from the master branch, should you wish to begin trying out the support for .NET Core. We wouldn't recommend going into production with a pre-release version of 2.3 though.

Comment by Henning Støverud [ 21/Jun/16 ]

Do you have an ETA for when this will be done and available on Nuget?

Comment by Robert Stam [ 17/May/16 ]

We are excited that .NET Core RC2 is now available and are actively working on support for .NET Core.

Stay tuned.

Comment by Alexander Pavlyuk [ 17/May/16 ]

Act!

Comment by Michael Lakerveld [ 17/May/16 ]

Update: Announcing .NET Core RC2 and .NET Core SDK Preview 1

https://blogs.msdn.microsoft.com/dotnet/2016/05/16/announcing-net-core-rc2/

Comment by Robert Stam [ 07/May/16 ]

Great news that RC2 will be available soon! Thanks for the heads up.

Comment by Michael Lakerveld [ 07/May/16 ]

Update from Microsoft: .NET Core and ASP.NET Core 1.0 RC2 runtime and libraries will be available in mid-May. RTM will be available by the end of June

https://blogs.msdn.microsoft.com/dotnet/2016/05/06/net-core-rc2-improvements-schedule-and-roadmap/

Comment by Robert Stam [ 23/Apr/16 ]

At this point we are waiting for .NET Core RC2 to come out. Even Microsoft has acknowledged that's a prudent course. Hopefully RC2 will come out soon.

Comment by Frédéric mériot [ 21/Apr/16 ]

+1 for a beta (RC1 compliant)

Comment by Matthias Jost [X] [ 05/Apr/16 ]

However bringing out a beta version would harm no one. Some libraries are currently doing so.

Comment by Matthias Jost [X] [ 05/Apr/16 ]

I believe not that anybody will go away. We are using the latest Visual Studio with the latest MVC. As long as the ASP.NET Core 1.0 CLR is not supported we just keep the reference to the full framework. Going then to the Core Framework, should be no big deal, since you already use the latest and greatest MVC with all the middleware stuff and so on.

Comment by David Nadaraia [ 05/Apr/16 ]

Seriously? Question is not when will you deliver CoreCLR support, question is how many people will move away from MongoDB

Comment by Robert Stam [ 22/Mar/16 ]

Thank you for your interest in using the .NET Driver with .NET Core.

We are currently working on this, but it will be a bit longer before we release it.

For one thing, .NET Core itself is not yet ready. There will be some significant changes in the RC2 version of .NET Core, some of which we are dependent on to make porting the .NET Driver to .NET Core easier (mainly in the reflection APIs).

Once .NET Core itself stabilizes more and Microsoft firms up their release schedule we will have a better idea of when we will release a version of the .NET Driver for .NET Core.

Comment by Bekasov Denis [ 22/Mar/16 ]

Our project neeeeeeeeds this support too!!!

Comment by Alexander Pavlyuk [ 22/Mar/16 ]

Seriously? It's almost April. We've got ongoing project using Mongo on ASP.NET Core and we absolutely need this ASAP. Please, hurry up.

Comment by nicoZeDodo [X] [ 10/Jan/16 ]

Is it possible to have a tentative date for this support, in order to decide if we can start our new development with mongoDb.

Comment by Benjamin Sellers [ 16/Dec/15 ]

It looks like NUnit and FluentAssertions both support CoreCLR now. Nsubstitute still doesn't have support (https://github.com/nsubstitute/NSubstitute/pull/197).

Comment by Matthias Jost [ 21/Sep/15 ]

We would also appreciate support for .NET Core.

Comment by Robert Stam [ 24/Aug/15 ]

Pull requests are always welcome. If we received a pull request we would evaluate it and decide what to do. Sometimes pull requests are accepted as is and sometimes they are used as starting points for further refinement. Thank you for your interest in contributing!

You should also look at:

https://github.com/mongodb/mongo-csharp-driver/pull/210

Which did some initial work of creating new project files as a first step towards supporting .NET Core. Read the comments in that pull request also. At this point the main obstacles seem to be that other tools we use for testing (NUnit, FluentAssertions and NSubstitute) don't yet support .Net Core.

Comment by Radi Atanassov [X] [ 24/Aug/15 ]

Would you be interested in a pull request if I do this port? I really need this and have to start on it anyway. I am more than happy to invest time, do it right then pass to you for consideration.

Comment by Robert Stam [ 07/Jul/15 ]

Not yet. You can watch this ticket to be notified of when work on this begins.

Comment by Bret Ferrier [ 06/Jul/15 ]

Is there a branch/fork somewhere in the ether that is at a beta level that supports .net core?

Comment by Craig Wilson [ 03/May/15 ]

No updates. We'll begin working on it shortly now that an RC has been put out. This is one of our highest priorities.

Comment by Michael Heinrich [ 03/May/15 ]

I'd also like to use mongodb with CoreCLR. Are there any updates yet?

Comment by mickdelaney [ 29/Jan/15 ]

Thats great news. Personally I'm hoping to migrate a bunch of services written in C# to Docker. Some of which are accessing Mongo.
CoreCLR + Async will be great.

Comment by Craig Wilson [ 29/Jan/15 ]

Yes. We have plans for it. We have been working on getting 2.0 done and since Core CLR is still not complete, we haven't spent much time playing with it. I've run some compatibility reports and we aren't all that far off.

Generated at Wed Feb 07 21:38:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.