Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 26, 2012 09:09 AM by svetsarn
Dec 25, 2012 11:34 AM|LINK
I have made a model with database first. I think this is very strange.
My Models are not in models folder, they are in a folder siteModel.tt and this folder is under sitemodel.edmx. Is this correct?
Also when I try to change the model it will go back to the way it was before. I noticed that it is partial classes so I maybe can add partial classes to my model folder? If I can, is there anybody that can explain to me how to do this?
Dec 25, 2012 12:01 PM|LINK
Don't modify the classes generated by tt otherwise you'll lose your changes on updating edmx from database. Create separate partial class to override the behaviors.
have a look at following:
Dec 25, 2012 01:50 PM|LINK
With MVC applications, you are not required to use the Models folder. This is merely to help with organizing your model files.
Also, you do not have extra folders; with EF 5.0, your EDMX file is associated with a set of TT (text template) files along with your code file. The Solution Explorer is showing the file association through the hierarchy of the files.
As for adding custom partial classes to your model, there should be no issues with this; however, you probably want to move your EF files into the Models folder as well.
Dec 26, 2012 09:09 AM|LINK
I got this working now. But I really want to have my partal classes in my models folder. If I store them in the models folder they will belong to another namespace and as I understand so must partial classes be in the same namespace.
I have changed the namspace in my partial class in the models folder so it work, is it ok to do that?
let say the namespace in my models folder is mySite.models, now I hav changed it to only mySite and it works fine.