Using EF Code First and SqlCe in WPF

前端 未结 4 1895
轻奢々
轻奢々 2021-02-10 08:08

I\'m trying to use EF Code First with my WPF application , the idea is to create a SqlCe Db in AppData/MyApp (if there isn\'t one) and use it with EF Code First.

At the

4条回答
  •  终归单人心
    2021-02-10 09:04

    Here is a possible clue. If you were to install EFCodeFirst.SqlServerCompact using NuGet Package manager, and look in: Visual Studio 2010\Projects\MyProject\packages\EFCodeFirst.SqlServerCompact.0.8.8482\Content, it does things for your web app like:

    public static class AppStart_SQLCEEntityFramework {
        public static void Start() {
            DbDatabase.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");
    
            // Sets the default database initialization code for working with Sql Server Compact databases
            // Uncomment this line and replace CONTEXT_NAME with the name of your DbContext if you are 
            // using your DbContext to create and manage your database
            //DbDatabase.SetInitializer(new CreateCeDatabaseIfNotExists());
        }
    }
    

提交回复
热议问题