ASP.NET MVC Model Design and migrations - asp.net

I'm preparing to start designing an ASP.NET MVC web application and plan to use the model designer to create objects which models will then be automatically and transprently created by ASP.NET using a specified database system (SQLite, or MSSQL, or other...).
I tried to find information about that, but nothing really clear for me as I am french, so sorry if my question were already asked somewhere. I would be very grateful for any help.
So the problem is, when I will need to migrate objects and data after adding features, improved the application workflow, etc..., how will ASP.NET MVC can manage the migration ? I guess I would need to use some migration framework such as MigratorDotNet ? But problem with this one for example : it needs to specify fields and tables as migration instructions, while ASP.NET MVC is intended to manage it all transparently.
I hope I explained well.
Thank you very much for your help !
EDIT :
What I wanted to ask, specifically and may be more simply is :
Is it possible to make my application model migration quite automatically based on comparison between previous and new model design made through the model designer ? If yes, how ? Thanks a lot !
EDIT 2 :
I think I found some answer on "Step 5: Changing our Model" of this page :
http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx using Database.SetInitializer() call on the Application_Start() handler.
EDIT 3:
I may have finally found my solution, the Entity Designer Database Generation Power Pack explained here : http://blog.nakedobjects.net/?p=137
Did anyone already try and use it in production ? Thanks !

Finally, I think this is the solution I will adopt :
http://blogs.msdn.com/b/adonet/archive/2010/02/08/entity-designer-database-generation-power-pack.aspx
I hope this will be usefull to anyone in the future !

Related

Learning Resources for Entity Framework 5

My team is looking to shift asp.net form application from .NET 4 to .NET 4.5. We are hoping that we would be able to use the whole new Entity Framework 5. Being the in charge of this task I did look into the advantages of using EF5 and I am quite impressed.
EF5 gives you the ability to run pre-compiled Queries and that will be a great performance boost.
Apart from that we would be able to use enums and table-valued functions, that I am not very excited about but lets see how these can improve Code Quality and maintenance.
My Question is, are there any good resources that can help me learn some practical implication of EF5. I have been searching for some time and hope that there are people out there who have already jumped to EF5 and can post some useful resources in here.
The answer is not exactly about EF but for "MVC with EF".
I'm learning MVC these days & I've learned quite a bit. I would like to share my experience and how the whole training can be highly effective. If you go systematic, everything is simple and cool. I would advise you to first cover some basic concepts which are used in MVC and entity framework:
Extension Types
Lambda Expression
LINQ
Anonymous Types
You can find good information on these at http://www.youtube.com/watch?v=FejRZ6QYWHw.
If you already know that you can skip.
Next you can start learning the EF. You can do so by following Lynda Tutorials which I found to be extremely simple and effective (avoid Plurasight as of now).
You can also visit asp.net website and check the Getting started with EF6 using MVC 5. It has wonderful list of articles, which I would recommend to everyone.
And once you are done with that, you should be capable enough to build any web application. If you want more higher level details you can then opt for Plurasight tutorials.
Hope this helps.

MVC3 IOC for beginners with Ninject

I'm trying to get my first internship, and one of the skills required is ASP.Net. They said I needed to bring some code in, so I went though Microsoft's MVC3 tutorial (http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/intro-to-aspnet-mvc-3)
I changed it around the app around a bit to suit their specifications, which they were fine with.
Now they've asked me to design an interface which will provide IOC. I'm completely new to the topic, and am wondering if anyone knows some good beginner's guides or tips on IOC with MVC. I'm probably going to use ninject.
If you're familiar with the 'movie list' app from the tutorial, they would like me to design an interface which will ensure that the MoviesController will have no awareness of the database.
I know that's pretty vague, but that's pretty much all the instructions they gave me. Anyone have some advice for a IOC newb?
Thanks!
You'll find it useful to read Scott Allen's article on abstracting away the dbContext to an interface, then read the MVC3 section of the ninject wiki to get your dependency resolution set up.
The basic idea is that you pass your controllers an object implementing a custom interface to the dbContext when you construct them, and thereafter you do all your data manipulation through that object/interface.
That way when you want to test your controllers, you can pass a dummy object that returns whatever data you need without having to create a database full of test data.

class library for asp.net applications

We are going to develop many small applications using asp.net (c#) with oracle database. I would like to write a simple class library say dataaccess.dll that has most of the functionality for connecting to database, executing a sql query, update or insert or delete etc so that i could reuse them in my many small projects. Is there a good example online somewhere that i can get started from?
Well, probably i didnt explain my question properly..
I am not looking for how to make asp.net connect to oracle or how to execute a query (throught odp.net) from asp.net .
I am looking for ways to construct a class library with methods such as connect(),executeQuery(),insert(),update(),delete() methods which would accept connectionstring,sql query text etc as parameters from any c# program. What i want is a generalized dataaccess code or guideline to develop one based on odp.net that i can reuse again and again.
Thanks.
Search around for ODP.net which is what you'll be using. This is a helpful search term, but you'll find a lot of examples for your specific needs.
Look for pages that explain how to set up your classes to use the connector such as http://ergemp.blogspot.com/2008/10/querying-oracle-with-c-and-odpnet.html
Make sure to pay attention to the type of objects you're using to select data and don't confuse SqlDataSource with OracleConnection.
Look for pages detailing the use of the Oracle client, Oracle.DataAccess.Client.
You may know most of this, but in case someone find this question and doesn't, they get some info.

ASP.NET MVC 3, MVCScaffolding Nuget : Re-creating tables

I'm currently developing a CMS for a website I'm making. I'm using MVCScaffolding to quickly make my controllers. Everything worked very well but...
I have a question. I created a new database so now I don’t have any of my tables in it yet. Is there any way of recreating my tables with a simple command? I tried hard to find a way but found nothing yet.
Anyone has an idea? I still have all my models, etc. I just want to recreate the tables so I could continue to use them.
Thanks a lot!
If you don't MVCScaffolding yet go take a look it is awesome!
http://blog.stevensanderson.com/2011/01/13/scaffold-your-aspnet-mvc-3-project-with-the-mvcscaffolding-package/
The answer is pretty simple : You have to run the app and access the module. It'll trigger the creation process.

How to implement Log4net for my Asp.net mvc application

I want to Implement Logging future using log4net for my asp.net mvc application..
Can any body has the Sample project so that I can take a look? and where do i need to find out the dll's for log4net?
Thanks
I Used this link to implement Loging for my application
http://www.codeproject.com/KB/aspnet/log4net.aspx
How do I need to log this error to my database table? what do I need to write in my Class? to store the values in the table
thanks
Get it from here.
Here are some examples.
Well to be honest you hardly made an effort if you couldn't find the DLLs, which are available here.
You will want to add the DLL as a reference in your project and then follow the directions here.
This guide might help you:
http://haacked.com/archive/2005/03/07/ConfiguringLog4NetForWebApplications.aspx
You can download the source code and the DLLs from here:
http://logging.apache.org/log4net/download.html

Resources