Do I need to use an oil-based primer on old woodwork?
Unfortunately, you're best bet is going to be to scrape off the primer. There are chemicals that will help make this easy, but in my experience a mechanical scraper is less of a hassle and mess. Something like this scraper will work if your trim is relatively flat and level.

Kilz has a number of products that will bond to various surfaces. I would buy a quart of Kilz Adhesion and apply a small amount to a sample area of your trim. Let it dry for a couple of days, then try your fingernail test again. If you still get flaking, try another product, like Kilz Complete.

If you don't want to scrape all of the trim down, you could also use a wire brush and aggressively brush down all of the trim. Whatever doesn't flake off is probably bonded well enough. But then you'll be left with low spots where you had flakes, which might be obvious if your trim is already in pretty good condition.