Using PetaPoco in Asp.NET Core MVC 6

2.9k views Asked by At

so i started trying out the new ASP.NET 5 Platform and have the following dependencies in my Project.json

"dependencies": {
    "System.Collections": "4.0.10-beta-23019",
    "System.Linq": "4.0.0-beta-23019",
    "System.Threading": "4.0.10-beta-23019",
    "System.Runtime": "4.0.10-beta-23019",
    "Microsoft.CSharp": "4.0.0-beta-23019",
    "PetaPoco.Core": "5.1.141-beta"
},

"frameworks": {
    "dnx451": { "dependencies": { "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta5" } },
    "dnxcore50": { "dependencies": { "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta5" } }
}

Everything builds fine but when i try to access anything from the PetaPoco namespace. Everything fails with the message.

The type or namespace PetaPoco could not be found, are you missing a using directive or an assembly reference.

I know what this means but even trying to import the namespace causes the same issue and I can see the library right there in the DNX4.5.1 AND DNX5.0 References

Please what Am i missing here

Thanks in advance

3

There are 3 answers

0
Plebsori On BEST ANSWER

You should be able to use PetaPoco with dnx451. However, you'll need to use the compiled nuget package, as the project structure has changed and the single file deploy won't be copying the source file to a valid location (My guess).

In addition and as per my comment, dnxcore50 (now .Net Core 1.0) is missing a component or two from the ado stack, which means PetaPoco won't work. However, targeting dnx451 should work.

Lastly, we'll mostly likely see PetaPoco builds for .NET/Asp.Net Core 1.0 after they release the RC2.

3
Magnus Karlsson On

You are missing that PetaPoco won't work with dnxcore50. Remove the following line to try out ASP.NET5 (or asp.net core as the new name is):

  "dnxcore50": { "dependencies": { "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta5
0
JCKödel On

https://github.com/JCKodel/Core.ORM

In the folder __PETAPOCO/XCore there is a functional PetaPoco version that runs on dnxCore. All tests pass.