asp.net mvc - Why is EF4 trying to re-create my database even though the model hasn't changed? -
i have asp.net mvc 3 beta website using sql server ce 4.0. both scottgu's nerddinner example , own code, following exception try access database:
file exists. try using different database name. [ file name = d:\sourcecode\nerddinner\nerddinner\app_data\nerddinners.sdf ] line 17: public actionresult index() line 18: { line 19: var dinners = d in nerddinners.dinners line 20: d.eventdate > datetime.now line 21: select d; [sqlceexception (0x80004005): file exists. try using different database name. [ file name = d:\sourcecode\nerddinner\nerddinner\app_data\nerddinners.sdf ]] system.data.sqlserverce.sqlceengine.processresults(intptr perror, int32 hr) +92 system.data.sqlserverce.sqlceengine.createdatabase() +1584 system.data.sqlserverce.sqlceproviderservices.dbcreatedatabase(dbconnection connection, nullable`1 timeout, storeitemcollection storeitemcollection) +287 system.data.objects.objectcontext.createdatabase() +84 system.data.entity.internal.databaseoperations.create(objectcontext objectcontext) +35 system.data.entity.infrastructure.database.create() +70 system.data.entity.infrastructure.createdatabaseonlyifnotexists`1.initializedatabase(tcontext context) +360 system.data.entity.infrastructure.database.initialize() +272 system.data.entity.internal.internalcontext.initialize() +90 system.data.entity.internal.internalcontext.getentitysetandbasetypefortype(type entitytype) +34 system.data.entity.internal.linq.efinternalquery`1.initialize() +140 system.data.entity.internal.linq.efinternalquery`1.get_provider() +29 system.data.entity.infrastructure.dbquery`1.system.linq.iqueryable.get_provider() +34 system.linq.queryable.where(iqueryable`1 source, expression`1 predicate) +63 nerddinner.controllers.homecontroller.index() in d:\sourcecode\nerddinner\nerddinner\controllers\homecontroller.cs:19
i cannot figure out why works existing .dbf file , other times complains. have tried explicitly setting default behaviour with
database.setinitializer(new createdatabaseonlyifnotexists<...>());
has else experienced this?
- restarting cassini doesn't seem make difference.
- hitting refresh in ie after receiving error make exact same page load properly.
install , use sql server ce ctp1, still downloadable on microsoft sites. solved problem that.
Comments
Post a Comment