none
Microsoft.EntityFrameworkCore not compatible with UWP in VS2017? RRS feed

  • Question

  • Hello,

    I have just installed VS2017 and attempted to try a simple UWP in VS2017 environments. After creating the project, I added a C# class into the project deriving from DbContext and got the compiler error saying:

    Severity Code Description Project File Line Suppression State
    Error CS0246 The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?) TestEntityFW D:\Frank\Test\TestVS2017\TestEntityFW\TestEntityFW\TestContext.cs 10 Active

    I have already installed the package SQLite from NuGet.

    Install-Package Microsoft.EntityFrameworkCore.Sqlite

    The simple class I created is: (I did not go far)

    using System;using System.Collections.Generic;

    using System.Linq;using System.Text;

    using System.Threading.Tasks;

    using Microsoft.EntityFrameworkCore.Sqlite;

    namespace TestEntityFW

    public class TestContext:DbContext 

    }

    }

    What is the issue? Have I missed something?


    • Moved by CoolDadTx Thursday, January 18, 2018 9:32 PM EF related
    Thursday, January 18, 2018 7:59 PM

Answers

  • Hi FrankTo,

    Due to limitations in the way .NET Core tools interact with UWP projects the model needs to be placed in a non-UWP project to be able to run migrations commands in the Package Manager Console.

    Please create a .Net standard Class library project to operate entity framework core, for more information, please refer to:

    https://docs.microsoft.com/en-us/ef/core/get-started/uwp/getting-started

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by FrankTo Saturday, January 20, 2018 1:27 PM
    Friday, January 19, 2018 6:15 AM
    Moderator

All replies

  • Did you create the model. With SQL server that is generic, I don't know how that is with SQLite, but from this page I understand that is in Microsoft  language. To be done.

    https://docs.microsoft.com/en-us/ef/core/get-started/netcore/new-db-sqlite


    Success Cor

    Thursday, January 18, 2018 8:09 PM
  • The link you provided seems to suggest creating the model from console? I would prefer to work on VS2017 environments.

    I have followed the tutorials from this site MSDN Magazine in Dec 2017 (2nd project) and also encountered the same issue.

    https://msdn.microsoft.com/magazine/1217magcode?f=255&MSPPError=-2147217396

    Do you have the same issue? Could you advise?

    Thursday, January 18, 2018 9:31 PM
  • Hi FrankTo,

    Due to limitations in the way .NET Core tools interact with UWP projects the model needs to be placed in a non-UWP project to be able to run migrations commands in the Package Manager Console.

    Please create a .Net standard Class library project to operate entity framework core, for more information, please refer to:

    https://docs.microsoft.com/en-us/ef/core/get-started/uwp/getting-started

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by FrankTo Saturday, January 20, 2018 1:27 PM
    Friday, January 19, 2018 6:15 AM
    Moderator
  • The answer shows a reference as to how to use SQLite i.e. Install-Package Microsoft.EntityFrameworkCore.Sqlite

    and if one changes the reference to Install-Package Microsoft.EntityFrameworkCore.SqlServer a package manager error is thrown saying 

    EntityFrameworkCore.SqlServer 2.0.1 is not compatible with uap10.0.10586 (UAP,Version=v10.0.10586). Package

    Microsoft.EntityFrameworkCore.SqlServer 2.0.1 supports: netstandard2.0 (.NETStandard,Version=v2.0)

    Attempts to load version 2.0.0 receives the error Package restore failed.

    What's the correct approach and where is it documented

    Friday, January 26, 2018 4:59 PM