Database Class Missing for MigratorDotNet - visual-studio-express

According to the Migrator.net Quick Start Tutorial, I'm supposed to invoke the Database class to invoke the migration, a la Database.CreateTable(...).
Problem is, I don't have any Database class in my project path. Visual Studio can't find it. (I installed this using NuGet, and it included three references: Migrator, Migrator.Framework, and Migrator.Providers.)
What am I missing? Here's a complete class, which looks correct (virtually an exact duplicate of the starter code on their wiki):
using System;
using System.Linq;
using System.Web;
using Migrator.Framework;
using System.Data;
namespace Migrations
{
[Migration(1)]
public class CreateModelTables_001
{
public void Up() {
Database.ExecuteNonQuery("");
}
}
}

Your migration is not extending the Migration class. Database is a member variable. Change your class definition to:
public class CreateModelTables_001 : Migration
And you should be good to go.

Related

Problem with trigger in OntTriggerEnter2D in unity

I have a two objects, both of them have : rigidbody2D of type dynamic, collider2D set to trigger, same layer, same Z position. But they do not collider with each other. One of them has a simple script attached, which contains function OnTriggerEnter2D, which just debug.log some message. As you can guess the console doesn't print the message. No errors tho. Please help! I've also tried to restart unity, even the PC - doesn't work as well.
function :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy : MonoBehaviour
{
private void OnTriggerEnter2D(Collider2D collision)
{
Debug.Log("DUOA");
}
}
Have a look at the Collision action matrix, you will not receive a trigger call from two dynamic Rigidbodies that both have a trigger collider component.
Change one of the Rigidbody types to Kinematic, which should resolve your issue.

.NET Framework name space structure (Directives)

For example "Using System.Console". Here "System" is the namespace and "Console" is the class"
Okay that makes sence but what about directives such as "System.IO.Compression".
In the above example would "Compression" be the method?
In visual studio projects why does the IDE add using system; and then using system.console?
Would using system automatically call all the classes in the namespace anyway making the using system.console redundant?
System, System.Console, System.IO, System.IO.Compression are all namespaces.
namespace System
{
class Foo1{}
namespace Console
{
}
namespace IO
{
class Foo2{}
namespace Compression{}
}
}
Compression namespace is nested inside IO, and all nested inside System
If you Using System, you only can access class Foo1(), in the other words, Using... only access class and variable, not the namespace that nested inside
***EDIT: This article defines quite clearly about namespace: https://msdn.microsoft.com/en-us/library/dfb3cx8s(v=vs.140).aspx

Moving Sitemesh3.xml to a different folder

I'm practicing web programming by using Spring 3.1, Hibernate and SiteMesh3.
I want to move 'sitemesh3.xml' file to other directory as WEB-INF/spring/ (not in WEB-INF directly). I've tried it, but sitemesh didn't work. Is it possible to move it? If it is, what properties, if any, should I add on other files like web.xml?
(I've read http://wiki.sitemesh.org/wiki/display/sitemesh3/Configuring+SiteMesh+3, which says "The configuration file should live in /WEB-INF/sitemesh3.xml in your web-application.")
Consider using java config, you can get rid of xml configuration totally.
Follow Sitemesh Java Config
Create a filter like this and register it in your web.xml or in java configuration file.
#WebFilter(urlPatterns = "/*")
public class ConfiguredSiteMeshFilter extends ConfigurableSiteMeshFilter {
#Override
protected void applyCustomConfiguration(SiteMeshFilterBuilder builder) {
builder.addDecoratorPath("/*", "/WEB-INF/decorators/defaultDecorator.jsp");
}
}

MvvmCross. It is not possible to add a custom dll reference to MvvmCross.Core library project

I'm trying to add a DLL to my MvvmCross.core library project. However the included namespaces cannot be resolved for some reason, when I'm trying to refer the namespaces from one of the ViewModels. In object viewer I can see the included namespaces.
When I refer the same DLL from MvvmCross.Droid project I do not see the problem.
Unfortunate I do not have the source code so I need to refer it as a DLL.
I have tried this both on VS2013 and Xamarin Studio
Is your MvvmCross.core project a portable class library? If it is you won't be able to reference it.
What you can do is create another platform specific project, MyThing.Droid, and reference the .DLL. In the MvvmCross.core project, create an interface, IMyThingService. In MyThing.Droid create, MyThingService that implements IMyThingService and does the stuff you want. Now you can get a reference to IMyThingService and call DoStuff() from the MvvmCross.core project.
You can also use the plugin model provided by MvvmCross to accomplish this.
public class MyThingService : IMyThingService
{
public void DoStuff()
{
}
}
public interface IMyThingService
{
void DoStuff();
}

How to work with Portable Class Library and EF Code-first?

I'm doing an Windows Phone app where I have a WebApi running in Azure.
I'm using the new "Portable Class Library" (http://msdn.microsoft.com/en-us/library/gg597391.aspx) for my "Models" project which is of cause shared between my WebApi project (this is a normale ASp.NET MVC 4 project) and my Windows Phone project.
This works great and the model (POCO) classes are serialized and deserialized just as I want.
Now I want to start storing some of my Models/POCO objects and would like to use EF Code-first for that, but that's kind of a problem as I can't add the EntityFramework assembly to my "Portable Class Library" project, and really I would not like to either as I only need a small part (the attributes) in my Models project.
So, any suggestions to how a approach this the best way?
UPDATE:
Well, it seems like I can actually add the EntityFramework assembly to the project, but that doesn't really help me, as the attributes I need to use lives in System.ComponentModel.DataAnnotations which can't be used on Windows Phone.
Any suggestions still?
Don't use attributes. Use fluent API instead and create separate assembly for persistence (EF) which will reference your model assembly. Persistence assembly will be use used by your WebAPI layer.
I use a modified approach than Mikkel Hempel's, without the need to use pre processing directives.
Create a standard .NET class library, call it Models
Create a partial class representing what you want to be shared
public partial class Person
{
public int Id { get; set; }
public string Name { get; set; }
}
For non-portable code (like DataAnnotations), create another partial class and use Metadata
[MetadataTypeAttribute(typeof(Person.Metadata))]
public partial class Person
{
internal sealed class Metadata
{
private Metadata() { } // Metadata classes shouldn't be instantiated
// Add metadata attributes to perform validation
[Required]
[StringLength(60)]
public string Name;
}
}
Create a Portable Class Library, and add the class from step 2 "As Link"
When I need my domain-project across multiple platforms, I usually:
Create the standard .NET-class library project for the domain code
For each platform I create a platform specific class library
For each platform specific class library I add the files from the standard .NET-class library as links (Add existing files -> As link) and hence they're updated automatically when you edit either the linked file or the original file.
When I add a new file to the .NET-class library, I add it as links to the platform specific class libraries.
Platform specific attributes (i.e. Table and ForeignKey which is a part of the DataAnnotations-assembly) can be opted out using the pre-processor tags. Lets say I have a .NET-class library with a class and a Silverlight-project with the linked file, then I can include the .NET-specific attributes by doing:
#if !SILVERLIGHT
[Table("MyEntityFrameworkTable")]
#endif
public class MyCrossPlatformClass
{
// Blah blah blah
}
and only include the DataAnnotations-assembly in the .NET-class library.
I know it's more work than using the Portable Class Library, but you can't opt out attributes in a PCL like in the example above, since you're only allowed to reference shared assemblies (which again DataAnnotations is not).