tag:blogger.com,1999:blog-4388210448295499283.post2499786924780543319..comments2023-07-03T10:41:00.692+02:00Comments on Jason's Architecture and .NET Blog: [Tutorial] Code First with Entity Framework 4.1 Part1: Introduction to the Code First approachJason De Oliveirahttp://www.blogger.com/profile/00420864903139404668noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-4388210448295499283.post-46000241674918201192012-03-27T13:16:52.159+02:002012-03-27T13:16:52.159+02:00Hello Gian,
I will try to look into that as soon ...Hello Gian,<br /><br />I will try to look into that as soon as possible and try to help you with this request.<br /><br />Greetings,<br />JasonJason De Oliveirahttps://www.blogger.com/profile/00420864903139404668noreply@blogger.comtag:blogger.com,1999:blog-4388210448295499283.post-3962225514911251512012-03-26T17:58:20.981+02:002012-03-26T17:58:20.981+02:00Hi,
I'm trying to use entity framework with an...Hi,<br />I'm trying to use entity framework with an adapter structure, my goal will be to have a single .edmx structure able to manage several connections. <br /><br />I need to have those adapters:<br />- file based database (SqlServerCE 3.5)<br />- MySql (with its custom provider from Oracle)<br />- Oracle (as MySql)<br />-SqlServer<br /><br />I have a DAO class that receives a bean (dependency injection object) with data connection from a winform, than due to a specific info in that bean, the DAO will load the correct adapter, through a Database factory class.<br />My Database factory will load a real adaptor class (e.g. for mysql A_Mysql.cs that implement my abstract adapter class).<br /><br />In particular, I would like to understand hop I can modify in the adaptor the connection method:<br /><br />public override Entities createConnection(DbConnection dbBean)<br /> {<br /> string conn =<br /> @"metadata=res://*/Toolkit.Database.External.ADO.ADODatabase.csdl" +<br /> @"|res://*/Toolkit.Database.External.ADO.ADODatabase.ssdl" +<br /> @"|res://*/Toolkit.Database.External.ADO.ADODatabase.msl;" +<br /> @"provider=MySql.Data.MySqlClient;" +<br /> "provider connection string=\"Persist Security Info=True;server=" + dbBean.Server + ";" +<br /> "Port=" + dbBean.Port + ";" +<br /> "User Id=" + dbBean.Username + ";"+<br /> "Password=" + dbBean.Password + ";" +<br /> "database=" + dbBean.Schema + "\"";<br /><br /> Entities entities = new Entities(conn);<br /><br /> return entities;<br /> }<br />to use the same .edmx, in my DAO…<br /><br />I was pretty sure that this was the right way, unfortunately this system is always returning me errors from SqlCE (I have generated the first .emdx from SqlServerCE, but it does not contain any informations about that database and my App.config file has NOT stored database informations)…<br /><br />Can you help me? Please write me back for further information, if needed.<br />Thank you.gian giacomohttps://www.blogger.com/profile/12814397410516891109noreply@blogger.comtag:blogger.com,1999:blog-4388210448295499283.post-65552652084625324682012-03-06T20:47:51.983+01:002012-03-06T20:47:51.983+01:00Hello Anup,
Unfortunately there is no solution to...Hello Anup,<br /><br />Unfortunately there is no solution to this problem in EF 4.1, the DB will always get regenerated if the model structure changes. <br /><br />You have to manually backup your data and restore it into the DB after regeneration if you want to avoid loosing your data.<br /><br />This may change in future versions of EF but for now this is the only solution.<br /><br />Also, you should not fill the DB with productive data until you are sure concerning the final structure.<br /><br />Regards,<br />Jason De OliveiraJason De Oliveirahttps://www.blogger.com/profile/00420864903139404668noreply@blogger.comtag:blogger.com,1999:blog-4388210448295499283.post-87323121720942793132012-03-06T12:10:16.421+01:002012-03-06T12:10:16.421+01:00Hi,
How can we avoid loosing data from tables whe...Hi,<br /><br />How can we avoid loosing data from tables when we make changes in models?<br />If we change in model classes then it's dropping DB and creating new DB.<br /><br />Please help!<br /><br />Thanks,<br />Anup MAnup Munothttps://www.blogger.com/profile/16788293003281759823noreply@blogger.comtag:blogger.com,1999:blog-4388210448295499283.post-42439562532072046492012-01-22T16:56:36.855+01:002012-01-22T16:56:36.855+01:00I am sorry there is a little error: As one of the ...I am sorry there is a little error: As one of the blog visitors pointed out, the connection string name should be CompanyDatabase in the web.Config file.Jason De Oliveirahttps://www.blogger.com/profile/00420864903139404668noreply@blogger.com