c# - Azure web site deployment throwing. Mislead between DataBaseFirst and CodeFirst -


i'm stuck "dreadful" error message trying deploy mvc web site on azure :

code generated using t4 templates database first , model first development may not work correctly if used in code first mode. continue using database first or model first ensure entity framework connection string specified in config file of executing application. use these classes, generated database first or model first, code first add additional configuration using attributes or dbmodelbuilder api , remove code throws exception.

database first workflow used scratch (adding ado.net entity data model element , following wizzard connecting azure sql server db). can't figure out why it's besetting me code first. using ef 6.0 t4 templates. generated dbcontext looks :

    public partial class myappentities : dbcontext     {         public myappentities()             : base("name=myappentities")         {         }          protected override void onmodelcreating(dbmodelbuilder modelbuilder)         {             throw new unintentionalcodefirstexception();         }          public virtual dbset<atype> atype { get; set; }         public virtual dbset<btype> btype { get; set; }         // etc.     } 

connection string looks this. copied both in dal project , startup project web config :

<add name="myappentities" connectionstring="metadata=res://*/myappmodel.csdl|res://*/myappmodel.ssdl|res://*/myappmodel.msl;provider=system.data.sqlclient;provider connection string=&quot;data source=ndkkyxvogj.database.windows.net;initial catalog=dbname;persist security info=true;user id=myuserid;password=pa$$word;multipleactiveresultsets=true;app=entityframework&quot;" providername="system.data.entityclient" /> 

app runs without problem on local machine.

deploying process on azure follow these steps.

  • create (custom creation) web site on azure , give db credentials

  • download publish profile azure dash board

  • in vs click publish start project , set following parameters :

  • -> profile : import downloaded profile
  • -> connection : connection set , validates
  • -> settings : not sure @ awaited here !!! tryed both connection settings : suggested connection strings , edmx connection string. :

    metadata=res:///myappmodel.csdl|res:///myappmodel.ssdl|res://*/myappmodel.msl;provider=system.data.sqlclient;provider connection string="data source=ndkkyxvogj.database.windows.net;initial catalog=mydb;persist security info=true;user id=databaseuser;password=pa$$word;multipleactiveresultsets=true;app=entityframework"

tryed comment onmodelcreating(). didn't work. tryed comment throw on unintentionalcodefirstexception(). didn't work either.

despite research on other q & a, couldn't find reliable solution. appreciated.

ok got ...

actually, falling on that post , that one, appears azure misleading between connection string names both given same in azure sql server , azure web site.

it has nothing whatsoever bad ef implementation between code first/model first or db first ...

so gave connection string name new 1 in web app config, context class constructor, , in azure web sites connection string name parameters ... , worked.

it real pain figuring out ...


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -