Entity Framework code first: update SetInitializer throws exception -


i've been looking strange error hours haven't found anything. have simple entity:

public class company {     public guid id { get; set; }     public string name { get; set; } } 

and here context:

public class mydbcontext : dbcontext {      public dbset<company> companies { get; set; }  } 

when running first time, works fine. but, when change entity (for example, put [key] attribute id), expected "model has changed" or error. so, enter in global.asax application_start:

database.setinitializer<mydbcontext> (new dropcreatedatabaseifmodelchanges< mydbcontext >()); 

this stuck. there no compile error, compiles without errors / warnings. but, when run project, following error:

description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code.

exception details: system.typeloadexception: genericarguments[0], 'mydb.data.mydbcontext', on 'system.data.entity.idatabaseinitializer1[tcontext]' violates constraint of type parameter 'tcontext'.

please, have clue? i'm using entity framework 4.1 (ctp5)

for unanswered question trawlers, has been answered above. never marked users. see comments above. on 1k views ! thats wasting lot of time... added this.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -