How to modify namespace in classes generated with the CTP5 DbContextGenerator template - entity-framework-ctp5

in my application I have created a EF model from my database. After I created my POCO classes with the CTP5 ADO.NET DbContextGenerator template. By the way I want modify the namespace of the POCO classes generated.
I tried to modify the namespace of the model (right click on the model->properties->namespace) and the CustomToolNamespace that I found on right clicking on the model file, but nothing.
Another thing is that if I try to right click on any of my entities in my model, the namespace it's how I want.
Should necessarily modify by hand in any file generated?
Thanks!

Try CustomToolNamespace on .tt files instead

Related

Class not available

İ create a project "Deneme". create a folder as "App_Code" and create a class Islem in this folder. Then i create new aspx page but i couldn't see this class.error message is "Deneme is available Deneme is not availabe" I couldn't understand. My friend cab see this class on his computer but I can't. I created a new webform default.aspx. I couldn't reach this class, but I can reach webform1.aspx in this folder.
provide namespace in your Islem.cs like this
namespace Deneme
{
public class Islem
{
// .... logic
}
}
create new class in App_Code folder, there is no namespace by default. so you can no access it.
Troubleshooting when you can't find a class
While working on the project, open the "Object Browser" from the "View" menu. Then in the textbox labeled "Search" type in "Islem" and see what comes up.
If the class doesn't come up at all, you're in the wrong project, or you didn't add the class like you think you did, or it's a different project and you need to add a reference.
If it does come up, take careful note of the class' complete namespace.
My guess
My guess is that you have a mismatch on the namespace. By creating the folder you created a sub-namespace by default, so you probably need to add something like this to the top of your code:
using Deneme.App_Code
or, if you don't want to add that for some reason, you can instantiate an instance of the class using its full name:
var o = new Deneme.App_Code.Islem();
Another guess
Make sure Islem.cs is set to compile. See this answer for instructions.
This is a weird situation but try this. Go to 14 line in your Default.aspx.cs file and press ctrl+.+enter then you will have a new Islem file i the root of your project. Rebuild and then your error will disappear. Then copy the code inside your original Islem to the new generated file. Remove the old Islem and move the new one to App_Code. Hope this help you.

How can I override 'base_edit' view for a type using portal_factory?

It seems that when I use the portal_factory tool for creating an instance of a type it disregards the view I've specified to override base_edit.
Here's what I've got setup:
Alias from edit to base_edit in the types tool.
View class that renders the view.
ZCML that that hooks on the view class to the appropriate interface.
Content class that implements the appropriate interface.
I know my overridden base_edit view works because it renders:
Once the object has been created it renders.
When I disable the portal_factory tool for the type.
When I use another name like custom_edit it also renders the overridden view, despite the type being enabled in the portal_factory tool.
Changing the alias to ##base_edit works too.
this way zope traversing makes an adapter lookup instead of attribute access and your edit view will be used.
afaik the ## forces an adapter lookup, without ## the first object thru acquisition is called and then an adapter
cc #juriejan
You don't need to customized the base_edit.cpt, you simply need to create a new CMF skin template called yourtypenamenormalized_edit.pt, where "yourtypenamenormalized" is your portal_type name lowercase and without spaces.
The original Archetype base_edit.cpt will look for a template called this way before applying all default macros.
After that I suggest you to fill this new template with all the code you'll find inside the default template, that is edit_macro.pt, then start to apply your changes.
Commonly the only macro you'll want to override is the body macro.

Creating a customized namespace in C# asp.net

To preface, I need to say that I am still in the learning stagings of asp.net
I need to create a custom namespace where I can place my DataObject.cs file
The namespace is .Components.Data
How do I go about doing this?
Thanks in advance
Put your class inside a namespace Components.Data { ... } block.

Custome activity buid by an activity file

How can I use custom code (activity file not codeactivity neither activitydesginer ) as an Activity inside a Reshosted workflow designer?
I was doing the following for any activity, which I build for each ( codeactivity & activitydesginer) files, and wirte:
new ToolboxCategory("new Toolbox")
{
Tools=
{
new ToolboxItemWrapper(typeof(Flowchart)),
new ToolboxItemWrapper(typeof(SimpleWebDesigner.TEST)),
....etc
AnyHelp?
If you're talking about loading an Activity loaded from a loose xaml file, you can do this.
You have to use the the ActivityXamlServices class to Load(filename) the file at runtime. When you do this, you get the deserialized Activity instance. Of course, you must have any relevant assemblies (any assembly referenced by Activities defined in the xaml file) either loaded in the AppDomain or available for loading where the Fusion loader can find them.
Once you do this, you can create a ToolboxItemWrapper passing in activityInstance.GetType().
One thing, since the Activity xaml file is an Activity which holds other Activities, you will get the default Designer, which only shows a blank header. There is no easy way* to expand the child Activities defined in the xaml file in the designer when you drop them on the design surface.
*I believe you can construct a class that implements IActivityTemplateFactory which you can pass to the ToolboxItemWrapper which can pass the root Activity defined within your xaml file, so that when you drag/drop the item from the toolbox it will automatically add all child Activities defined in the xaml file. But I've never done this and am not sure if you can.

What's the base class of a Razor View in ASP.NET MVC3

I'm trying to have all my views inherit from a custom class so that I can add certain behaviour and values to all pages, but I'm having some issues. I tried subclassing System.Web.Mvc.WebViewPage but I'm forced to implement an Execute procedure that I don't know what it should do. Also, if I try to access the Context variable, I get a null reference (really weird). This leads me to think that I may have the wrong base class....
Any thoughts?
Diego, System.Web.Mvc.WebViewPage is the right base type (and you should have another class inheriting from System.Web.Mvc.WebViewPage<TModel> if you want strongly-typed views). You should mark your own class as abstract so that you are not forced to implement the Execute method.
Update: To configure all your views to use your custom base class, look into the ~\Views\Web.config file. Inside of it there's a Razor-specific section where you can use the pageBaseType attribute to configure your custom type.
As far as the Context property is concerned, it should be fully initialized once the view is executing. However, it might not be available if you try to access it too early (for example, from your classes constructor). When are you trying to access it?
The Execute method is something that is provided by the Razor compiler when your view is compiled. For example, given the following view file
Hello #Name!
The Razor compiler will behind the scenes generate the following class (this is a simplification, so the details might be off, but it should convey the point)
public class _Some_Generated_Class_Name_ : System.Web.Mvc.WebViewPage {
public void Execute() {
Write("Hello ");
Write(Name);
Write("!");
}
}
Then the framework calls the Execute method on your view class and your view gets executed.

Resources