Problem with RunMigrations in SimpleRepository Example - Subsonic 3 - subsonic

I downloaded today Subsonic 3 and tried out the examples. I am having a problem with the SimpleRepository example and I wondered if anyone else has had this. In the HomeController there is a defintion as follows:
public HomeController() {
_repo = new SimpleRepository("Blog");
}
I wanted to enable the migrations and so changed it to this:
public HomeController() {
_repo = new SimpleRepository("Blog", SimpleRepositoryOptions.RunMigrations);
}
However, when this runs it causes an error - stating an issue "String or binary data would be truncated.".
If it makes a difference, the version of VS is 2008 (with the GDR applied)
This is still an issue in the latest 3.0.0.1 and .2 downloads..

You get this error message if the migration you are trying to run would edit/truncate data in your database.
Do you have sql profiler available? That way you can see the sql statement. If you don't have sql profiler available you will need to download the source and use debug to see the actual sql statement that it is trying to execute.

Way way way late to this party, but you probably need to add the [SubSonicLongString] attribute to the columns that have more than the default 225 characters for a plain String.

Related

How to set up prefix for steps method for whispering in Intellij

If cucumber step definition starts with value, then IntelliJ doesn´t whisper code and we need to copy/paste it. Guys from team agreed to put some prefix unique for each method/process to help IntelliJ whisper. There is also condition that already existing steps which begins with value should be accepted as usual without any necessary code change.
I have tried to do something like code below to accept value or prefix with pipe but IntelliJ doesn´t whisper but code pass without error.
#Given("^DB:SQL UPDATE |.*, SQL UPDATE: (.*)$")
public void update(String sql) throws SQLException {
.......
We expect IntelliJ to whisper code using this prefix and others when writting step definintion like this:
Scenario Outline: Task list for team inbox filtered by org units
Given Empty OrgUnits table, SQL UPDATE: DELETE FROM r_org_unit
SOLVED:
#And("^.*, SQL UPDATE: (.*)$")
#Then("^DB:SQL .*, SQL UPDATE: (.*)$")
public void update(String sql) throws SQLException {
From now when you start writting code like
And up... IntelliJ will whisper you as well as
And DB... also whispering method
Thanks.

The specified target migration '201201230637551_Migration' does not exist?

I'm using EntityFramework 4.3 beta version and its Data Migration facility. I wrote following code for generating a custom Migration and apply it to the DB.
MigrationScaffolder ms=new MigrationScaffolder(configuration);
ScaffoldedMigration scaffoldedMigration= ms.Scaffold("Migration");
DbMigrator dbMigrator = new DbMigrator(configuration);
dbMigrator.Update(scaffoldedMigration.MigrationId);
Scaffolding function worked fine and generated a Migration correctly.
But an exception comes up and says
"The specified target migration '201201230637551_Migration' does not
exist. Ensure that target migration refers to an existing migration
id."
Does this happen since still this is a beta version? Can someone help me to solve this.
Thank you.
This is not because you were using a beta version. MigrationScaffolder class is only to generate a configuration class. That generated file is not being added to the solution automatically. If we want to pass it into DbMigrator.Update() method, we should add the generated file into the solution first. Then we should make an instance of that class, and pass it into the update() method like this.
{
DbMigrationsConfiguration myConfiguration=new MyConfiguration();
DbMigrator dbMigrator = new DbMigrator(configuration);
dbMigrator.Update(myConfiguration);
}
Here MyConfiguration is the generated class.
Additionally, you do not need to apply migrations into your project this way. Instead you can use:
{
DbMigrationsConfiguration myConfiguration=new DbMigrationsConfiguration(){
AutomaticMigrationsEnabled = true;
AutomaticMigrationDataLossAllowed = true;
}
DbMigrator dbMigrator = new DbMigrator(configuration);
dbMigrator.Update(myConfiguration);
}

SubSonic 3 isn't generating Foreign Key tables as a property

Basically, I'm having the same problem as detailed here, but in SubSonic 3.0. Unfortunately, I can't figure out how to change the provider in SubSonic 3.0.
Is this something I need to change in the MySQL.ttinclude, Settings.ttinclude or one of the T4 templates? Or does it go in config somewhere?
Thoughts? Suggestions?
I found this that says that it's as designed. I can't imagine why. I changed the Classes.tt file to generate a single mapping. The relevant code is below. However, this relies on the fact that all my PKs are named Id, but you should be able to get the idea.
Before the IQueryable<> generation part:
if (fk.ThisColumn == "Id")
{
//This is where the standard IQueryable goes
} else {
//This is what I added
public <#= fk.OtherTable #> <#= fk.OtherTable #>
{
get
{
var db=new <#=Namespace #>.<#=DatabaseName#>DB();
return from items in db.<#=fk.OtherQueryable #>
where items.<#=fk.OtherColumn#> == _<#=fk.ThisColumn#>
select items;
}
}
}
Hopefully that helps. I'm trying to figure out now to do many to many tables now :/
I am using Subsonic 2.2 and I am facing the same issue, but this worked on my problem: Apart from original provider MySqlDataProvider, there is an extended version: MySqlInnoDBDataProvider
So in your web.config, making sure the provider is choosn:
<add name="MyProvider"
type="SubSonic.MySqlInnoDBDataProvider, SubSonic"
connectionStringName="WriteConnectionString"
generatedNamespace="AttendAnywhere.Data"
generateLazyLoads="true"
extractClassNameFromSPName="true" />

Using log4net as a logging mechanism for SSIS?

Does anyone know if it is possible to do logging in SSIS (SQL Server Integration Services) via log4net? If so, any pointers and pitfalls to be aware of? How's the deployment story?
I know the best solution to my problem is to not use SSIS. The reality is that as much as I hate this POS technology, the company I work with encourages the use of these apps instead of writing code. Meh.
So to answer my own question: it is possible. I'm not sure how our deployment story will be since this will be done in a few weeks from now.
I pretty much took the information from these sources and made it work. This one explains how to make referencing assemblies work with SSIS, click here. TLDR version: place it in the GAC and also copy the dll to the folder of your targetted framework. In my case, C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727. To programmatically configure log4net I ended up using this link as reference.
This is how my logger configuration code looks like for creating a file with the timestamp on it:
using log4net;
using log4net.Config;
using log4net.Layout;
using log4net.Appender;
public class whatever
{
private ILog logger;
public void InitLogger()
{
PatternLayout layout = new PatternLayout("%date [%level] - %message%newline");
FileAppender fileAppenderTrace = new FileAppender();
fileAppenderTrace.Layout = layout;
fileAppenderTrace.AppendToFile = false;
// Insert current date and time to file name
String dateTimeStr = DateTime.Now.ToString("yyyyddMM_hhmm");
fileAppenderTrace.File = string.Format("c:\\{0}{1}", dateTimeStr.Trim() ,".log");
// Configure filter to accept log messages of any level.
log4net.Filter.LevelMatchFilter traceFilter = new log4net.Filter.LevelMatchFilter();
traceFilter.LevelToMatch = log4net.Core.Level.All;
fileAppenderTrace.ClearFilters();
fileAppenderTrace.AddFilter(traceFilter);
fileAppenderTrace.ImmediateFlush = true;
fileAppenderTrace.ActivateOptions();
// Attach appender into hierarchy
log4net.Repository.Hierarchy.Logger root = ((log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository()).Root;
root.AddAppender(fileAppenderTrace);
root.Repository.Configured = true;
logger = log4net.LogManager.GetLogger("root");
}
}
Hopefully this might help someone in the future or at least serve as a reference if I ever need to do this again.
Sorry, you didn't dig deep enough. There are 5 different destinations that you can log to, and 7 columns you can choose to include or not include in your logging as well as between 18 to 50 different events that you can capture logging on. You appear to have chosen the default logging, and dismissed it because it didn't work for you out of the box.
Check these two blogs for more information on what can be done with SSIS logging:
http://consultingblogs.emc.com/jamiethomson/archive/2005/06/11/SSIS_3A00_-Custom-Logging-Using-Event-Handlers.aspx
http://www.sqlservercentral.com/blogs/michael_coles/archive/2007/10/09/3012.aspx

Is it possible to use ASP.NET Dynamic Data and SubSonic 3?

Is it possible to use ASP.NET Dynamic Data with SubSonic 3 in-place of Linq to SQL classes or the Entity Framework? MetaModel.RegisterContext() throws an exception if you use the context class that SubSonic generates. I thought I remembered coming across a SubSonic/Dynamic Data example back before SubSonic 3 was released but I can't find it now. Has anyone been able to get this to work?
I just got Subsonic 3.0.0.4 ActiveRecord working last night in Visual Studio 2010 with my SQLite database after a little bit of work and I've tried to document the steps taken here for your benefit.
Start by adding a New Item -> WCF Data Service to the project you're using to host your webapp/webservices then modify it similar to my PinsDataService.svc.cs below:
public class PinsDataService : DataService<PINS.Lib.dbPINSDB>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.UseVerboseErrors = true;
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
}
At this point your Dynamic Data Service would probably be working if you matched all the database naming conventions perfectly but I didn't have that kind of luck. In my ActiveRecord.tt template I had to prepend the following two lines before the public partial class declarations:
[DataServiceKey("<#=tbl.PrimaryKey #>")]
[IgnoreProperties("Columns")]
public partial class <#=tbl.ClassName#>: IActiveRecord {
I then added references to System.Data and System.Data.Services.Client followed by the inclusion of using statements for using System.Data.Services and using System.Data.Services.Common at the top of the ActiveRecord.tt template.
The next step was to use the IUpdateable partial class implementation from this blog post http://blogs.msdn.com/aconrad/archive/2008/12/05/developing-an-astoria-data-provider-for-subsonic.aspx and change the public partial class dbPINSDB : IUpdatable to match my subsonic DatabaseName declared in Settings.ttinclude
Then to consume the data in a separate client app/library I started by adding a 'Service Reference' named PinsDataService to the PinsDataService.svc from my client app and went to town:
PinsDataService.dbPINSDB PinsDb =
new PinsDataService.dbPINSDB(new Uri("http://localhost:1918/PinsDataService.svc/"));
PinsDataService.Alarm activeAlarm =
PinsDb.Alarms.Where(i => i.ID == myAA.Alarm_ID).Take(1).ElementAt(0);
Note how I'm doing a Where query that returns only 1 object but I threw in the Take(1) and then ElementAt(0) because I kept getting errors when I tried to use SingleOrDefault() or First()
Hope this helps--also, I'm already aware that dbPINSDB is a really bad name for my Subsonic Database ;)

Resources