How to create bootstrapper class for Entity Framework 4.3 and SQL Server Compact 4.0
( TL; DR version is the question in bold at the bottom)
When Entity Framework 4.1 Code First was originally released (actually it was CTP5 time) there was a NuGet package named
. This can be used in conjunction with another named NuGet package to
enable EF to be used with SQL Server Compact 4.0 (SQL Server CE).
Installing the package
would create a scaffold or create a "bootstrapper" class named
in the folder
that would configure things like EF
and generate "stubs" for other useful methods (initialization, db seeding, etc.) using
These two packages (
) is now obsolete and it seems replaced by an equivalent package
, and both of them are on version 4.3.1 now
My problem is, using these new packages in a new project, they don't seem to create a "bootstraper" class to set up EF to use SQL Server Compact at runtime. Of course, I can just copy the old version of the class from a previous project, but it would be nice to know that the NuGet package still contains this functionality (which could potentially be updated over time).
Is there a way to get the latest version (4.3.1 at the time of this writing) of the package
to create the boottrapper class,
either after installation or after the fact (perhaps via the powershell command?)?
I just noticed that the previous version of
NuGetPackage still has a dependency on the package
(which is used by the bootstrapper class), however this dependency was removed from the latest version and one prior to the latest version . It looks like the functionality that generates the bootstrapper class has been removed, but why am I wondering?
source to share
In EF 4.1, the only way to do Code First is to create a SQL Server Compact database by convention (that is, without explicitly specifying a connection string) is to set the DefaultConnectionFactory to your code. This is problematic because tools (such as Migrations), which need to know which database are in use, don't know that code is present.)
In EF 4.3, we added the ability to do this in the web.config file. The EntityFramework.SqlServerCompact package takes advantage of this by setting the SQL Conmpact as the default factory connection in your web config. So you don't need to use a WebActivator or code to do this.
You can still use the code method if you want ypu, but keep in mind that things like Migrations may not work correctly and we recommend that you use a config file instead.
source to share